1

I am running chalice local inside virtual environment. I don't see the libraries installed in virtual environment. From inside chalicelib/common.py, I see the path (sys.path) to be set at:

['/home/sudip/myapp', '/usr/local/bin', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']

But when I run python3.6 from virtual environment console, I see this:

(venv) myapp$ python3.6
Python 3.6.5 (default, Mar 29 2018, 03:28:50) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print (sys.path)
['', '/home/sudip/myapp/venv/lib/python36.zip', '/home/sudip/myapp/venv/lib/python3.6', '/home/sudip/myapp/venv/lib/python3.6/lib-dynload', '/usr/lib/python3.6', '/home/sudip//myapp/venv/lib/python3.6/site-packages']
>>> 

Here the path is properly set. Why is this not happening in the former case? Hence I am getting lot of module import errors when I run my application, as for example: ModuleNotFoundError: No module named 'jwt'. Can anybody help?

tripleee
  • 175,061
  • 34
  • 275
  • 318
SudipM
  • 416
  • 7
  • 14

1 Answers1

0

You need to create your virtualenv with the option --system-site-packages to get access to the system (and site) packages:

virtualenv -p python3 --system-site-packages myvenv
ofrommel
  • 2,129
  • 14
  • 19