0

I'm trying to run python scripts from a MATLAB compiled application (Using MATLAB Compiler) and for some weird reason it can't find any import from scipy. When I try to call any scipy method it gives me this error

Python Error: ImportError: cannot import name sigtools

If I call the same code from Python or MATLAB directly, it works. But not from MATLAB Compiler.

Another weird thing is that the python path that the python call from MATLAB sees is correct, so what could cause this?

EDIT My python path

/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0

I have the file sigtools.x86_64-linux-gnu.so in

/usr/lib/python2.7/dist-packages/scipy/signal/
10
  • not enough information. Where is sigtools, what is you sys.path, have you even installed sigtools, etc, etc. Commented Nov 8, 2017 at 8:56
  • I have this file sigtools.x86_64-linux-gnu.so in my /usr/lib/python2.7/dist-packages/scipy/signal/ directory, so I'm assuming that it is installed. Another information is that if I call the same code from python directly it works, the same if I call from directly from MATLAB, not the MATLAB compiler version of it. Thanks for your help Commented Nov 8, 2017 at 9:00
  • 1
    If it is where you claim it is, then it's obvious sys.path wouldn't find it. But import scipy.signal.sigtools should work. Commented Nov 8, 2017 at 9:06
  • I presume your in Linux, can you able to located the sigtools.so lib in your Linux host? Commented Nov 8, 2017 at 9:08
  • It gave me this beautiful error Python Error: ImportError: cannot import name sigtools =(, there's anyway to directly give it the path to my sigtools.so? Commented Nov 8, 2017 at 9:08

2 Answers 2

1

I found the solution of the problem. The version of libstdc++ provided by MATLAB runtime environment is too old for importing some python libraries. It should libstdc++.so.6 version 3.4.21. I've replaced the file libstdc++.so.6 with an updated version (3.4.21) in v901/sys/os/glnxa64/ which is the MATLAB runtime directory.

Sign up to request clarification or add additional context in comments.

Comments

0

Answer to your question.

Go directly to the location of where sigtools.so lib is located in your machine and do python -c "import sigtools" and then in your file, you can import it.

3 Comments

Can you explain why this should work? All you're doing is importing the file to create the .pyc file. This can be done from any directory and besides, the code has been stated to work for Python and Matlab directly, so I can't see how that would resolve the problem.
this do not work from MATLAB, I said it works, but when I use python only, from matlab side it gives me Python Error: ImportError: cannot import name sigtools. It seems that MATLAB messes up something in the python path when It starts its python calls.
Checking in the MATLAB run-time directory (required to run executable without MATLAB), I've found some python files and one called my attention. It seems to be python code that queries python for the information necessary to initialize an embedded interpreter. inside it, there's a class called LibraryFinder, maybe there's a bug in it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.