Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtualenv not copying the existing python modules

python -c 'import pyscopg2'

this works fine.

Now I create a virtualenv

virtualenv venv

and activate it

source venv/bin/activate

and run the following

python -c 'import pyscopg2'

But it gives error 'ImportError: No module named pyscopg2'

like image 409
Jibin Avatar asked Aug 10 '26 07:08

Jibin


1 Answers

You should create virtual environment using --system-site-packages option to access system package.

According to virtualenv --help:

--no-site-packages    Don't give access to the global site-packages dir to
                      the virtual environment (default)
--system-site-packages
                      Give access to the global site-packages dir to the
                      virtual environment
like image 167
falsetru Avatar answered Aug 13 '26 14:08

falsetru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!