Matlab Engine in Pycharm works Debug mode but not Run mode

14 views (last 30 days)
I am experiencing a very odd behavior when importing the matlab engine inside of pycharm. I can run the script from the terminal, or with the Debug (bug icon) in Pycharm. However I cannot run the script with the 'Play' button in Pycharm and I have no idea what the cause is. Here is the script I am trying to run
import matlab.engine
eng = matlab.engine.start_matlab()
x = 4.0
eng.workspace['y'] = x
a = eng.eval('sqrt(y)')
print(a)
Again this works perfectly fine from the terminal or with the Pycharm Debugger, but with the regular 'Run' button I get this message
Traceback (most recent call last):
File "/home/markd/.pyenv/versions/airsim/lib/python3.6/site-packages/matlab/engine/__init__.py", line 45, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/home/markd/.pyenv/versions/3.6.11/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'matlabengineforpython3_6'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/markd/.pyenv/versions/airsim/lib/python3.6/site-packages/matlab/engine/__init__.py", line 63, in <module>
pythonengine = importlib.import_module("matlabengineforpython"+_PYTHONVERSION)
File "/home/markd/.pyenv/versions/3.6.11/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /usr/local/MATLAB/R2020b/extern/engines/python/dist/matlab/engine/glnxa64/../../../../../../../bin/glnxa64/libssl.so.1.1: undefined symbol: EVP_idea_cbc, version OPENSSL_1_1_0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/markd/Projects/TestProject/matlab/EngineTest.py", line 1, in <module>
import matlab.engine
File "/home/markd/.pyenv/versions/airsim/lib/python3.6/site-packages/matlab/engine/__init__.py", line 66, in <module>
'MathWorks Technical Support for assistance: %s' % e)
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: /usr/local/MATLAB/R2020b/extern/engines/python/dist/matlab/engine/glnxa64/../../../../../../../bin/glnxa64/libssl.so.1.1: undefined symbol: EVP_idea_cbc, version OPENSSL_1_1_0
My configuration:
  • ubuntu 20.04
  • Matlab 2020b
  • Python 3.6 as a virtual environment located at .pyenv/versions/airsim
  • I have write access to matlab and python installation directories, and installed by activating the virtual environment in a terminal and executing 'python setup.py install' and had no errors come up when installing
  • Pycharm project interpreter is set to my virtual environment python (again it works in debug mode just fine!!!)
  • Pycharm Professional Edition 2020.3.3
Any ideas? I've tried setting python path environment variable in pycharm to explicitly include 3.6/site-packages/matlab directory but that did not seem to help (and still doesn't explain why it works fine in Debug mode/terminal). Thank you!
  1 Comment
Mark Debord
Mark Debord on 19 Mar 2021
For anyone else experiencing this, my temporary fix for this is to edit the run configuration:
  • Under Run/Debug configuration->Configuration->Execution->Check 'Run with Python Console'
This drops you into a seperate console where the script will work fine, but not within the regular Pycharm environment

Sign in to comment.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!