IPython: Error loading DLL: the specified module was not found; simple python fine

I keep getting this (known) error in iPython. However, the same import works fine in plain Python. (Python 3.3.5, see details below)

IPython:

Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:37:12) [MSC v.1600 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. IPython 2.0.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython features. %quickref -> Quick reference. help -> Python own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: import test1 --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-7-ddb30f03c287> in <module>() ----> 1 import test1 ImportError: DLL load failed: The specified module could not be found. 

Python (not only does it load perfectly, but it also works):

 $ python Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:37:12) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import test1 >>> 

Now, Dependency Walker on test1.pyd shows it

 [ ? ] LIBGCC_S_DW2-1.DLL Error opening file. The system cannot find the file specified (2). [ ? ] LIBSTDC++-6.DLL Error opening file. The system cannot find the file specified (2). [ ? ] PYTHON33.DLL Error opening file. The system cannot find the file spec 

I even rewritten sys.path in iPython with one of simple Python. The file test1.pyd is located in C: \ Test.

 ['c:\\Test', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\python33.zip', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\DLLs', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\lib', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\lib\\site-packages', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\lib\\site-packages\\FontTools', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\lib\\site-packages\\win32', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\lib\\site-packages\\win32\\lib', 'c:\\WinPython-32bit-3.3.5.0\\python-3.3.5\\lib\\site-packages\\Pythonwin'] 

Why will import work in plain Python, but not in iPython?

+2
python ipython
Aug 31 '15 at 0:58
source share
1 answer

I ran into the same problem. After several hours of searching and thinking, I found out the reason. The difference is in the environment variables between the interpreters (regular python and ipython or pycharm, etc.). I think you can use %env in ipython to check environment variables. In simple Python, use (works in Python 3.7):

 import os os.environ 

Then, if there are differences, maybe you should set the right one before your run.

There are actually several ways to install envs. for example

 os.environ['key']='value' #Both key and value are strings 

or

 os.putenv('key', 'value') 

Here, key is the name of the environment variable, and value is the value you want to set.

Hope this helps you. ~~~ /// (^ v ^) \\ ~~~

0
Dec 15 '16 at 6:55
source share



All Articles