I recently copied my "scripts" folder to a seperate partition (from C:\ to drive D:\ ) while the python interpreter (v2.7.13) is still on C:\ . Subsequently I updated my $PATH to include the new path.
Now I try to execute a python script that imports modules from my "scripts" and it cannot find those modules:
Traceback (most recent call last):
File "neue_aufgabe.py", line 15, in <module>
from CustomUtils.UI.PyQtUI import *
ImportError: No module named CustomUtils.UI.PyQtUI
So, we have:
Interpreter on C:\
Modules on D:\
Script to be run on D:\
I deleted all the stale pyc files from all module directories. Is it just that the interpreter cannot import a module from a seperate partition?
You need to append your new folder to PYTHONPATH environment variable rather than PATH.
Alternatively you can set it in the script itself by putting this at the top (though not usually recommended in production)
import sys
sys.path.append('/path/to/your/modules')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With