I'm running python3 in a virtual environment, but when I try to import newly install packages, I get a ImportError: No module named ...
error message, despite seeing that package when I run !env/bin/pip3 list
.
When I type sys.path
I don't see any paths to my virtualenv:
['',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload',
'/Users/zurfarosa/Library/Python/3.5/lib/python/site-packages',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages',
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/extensions',
'/Users/zurfarosa/.ipython',
'/Users/zurfarosa']
How do I add my virtual env to my PYTHONPATH?
In my case I had to change interpreter, because default was global, not the one in virtual env.
Output printing paths in
sys.paths
(whereimport
is looking):Having changed IDE interpreter to
Python.exe
inside virtual environment directory, now gives:To change interpreter in VSCode click at the bottom right (env interpreter active in screenshot):