Reputation: 293
I have seen many more or less related questions on this topic, but none helped me finding a way to solve my problem. I'm not very familiar with Windows environment, deep apologies if my question sounds obvious to some extent.
Setup:
Im running a Python, that involves several modules import. I came across some module issues. For example:
from PIL import Image as PIL_Image
Works smooth in Spyder, but gives (error message in french but I guess you got the point):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\my_user_name\Anaconda3\lib\site-packages\PIL\Image.py", line 64, in <module>
from . import _imaging as core
ImportError: DLL load failed: Le module spécifié est introuvable.
If executed in Powershell or cmd.
What I tried:
Appending Anaconda's install path to my path variable before I open Powershell:
$Env:path += ";C:\Users\my_user_name\Anaconda3;C:\Users\my_user_name\Anaconda3\Scripts"
Checking that sys.path is the same in Powershell and Spyder. For both, it looks like:
['',
'C:\\Users\\my_user_name',
'C:\\Users\\my_user_name\\Anaconda3\\python37.zip',
'C:\\Users\\my_user_name\\Anaconda3\\DLLs',
'C:\\Users\\my_user_name\\Anaconda3\\lib',
'C:\\Users\\my_user_name\\Anaconda3',
'C:\\Users\\my_user_name\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\my_user_name\\Anaconda3\\lib\\site-packages',
'C:\\Users\\my_user_name\\Anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\my_user_name\\Anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\my_user_name\\Anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\my_user_name\\Anaconda3\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\my_user_name\\.ipython']
What else could explain that my import fails outside of Spyder ?
Upvotes: 2
Views: 3654
Reputation: 1
I had the same problem when importing scipy related modules and after struggling for days, this solution had worked for me:
How I solved my issue:
X:ProgramDataAnaconda3
--> C:\Program Files\Anaconda3
X:ProgramDataAnaconda3Scripts
--> C:\Program Files\Anaconda3\Scripts
X:ProgramDataAnaconda3Librarybin
--> C:\Program Files\Anaconda3\Library\bin
Paths might differ based on your installation folder.
Upvotes: 0
Reputation: 293
Ok I could not find a clean way out, so let me just share my experience in case someone finds it helpful ...
The DLL failure with PIL related libs seems to be a known issue. See further explanations:
How I solved my issue:
Upvotes: 2