Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'virtualenv' 'pip install sqlalchemy' but 'pip list' can not see

I learned to install a virtual environment of python.

It seems I am not quite familiar some basic pip common sense.

That is,

In the virtualenv,

virtualenv test

then I have a virtual environment which name is test.

then I activated it by

source ./test/bin/activate

Then I enter the virtual environment

firstly I run pip list to check the packages

pip list

then I got 'pip' and 'setup tools'

then I install 'sqlalchemy'

pip install sqlalchemy

I got the information 'successfully installed sqlachemy' but when I check the installed packages by

pip list

I still got only 'pip' and 'setuptools' without 'sqlalchemy'.

I am wondering why this happened.

Is the 'sqlalchemy' not one of the python packages?

And I have checked the './test/lib64/python2.7/dist-packages/'

I saw the 'sqlalchemy' folder right under that directory.

Is there anybody tell me why?

Thanks.

by the way, I check the 'sys.path' variable, I found that the value is equal to

/home/worker/pyproject/testenv/local/lib64/python2.7/site-packages
/home/worker/pyproject/testenv/local/lib/python2.7/site-packages
/home/worker/pyproject/testenv/lib64/python2.7
/home/worker/pyproject/testenv/lib/python2.7
/home/worker/pyproject/testenv/lib64/python2.7/site-packages
/home/worker/pyproject/testenv/lib/python2.7/site-packages
/home/worker/pyproject/testenv/lib64/python2.7/lib-dynload
/home/worker/pyproject/testenv/local/lib/python2.7/dist-packages
/home/worker/pyproject/testenv/local/lib/python2.7/dist-packages
/home/worker/pyproject/testenv/lib/python2.7/dist-packages
/usr/lib64/python2.7
/usr/lib/python2.7

But actually, the 'sqlalchemy' is installed in the directory /home/worker/pyproject/testenv/lib64/python2.7/dist-packages/

Why 'sys.path' does not contain this /home/worker/pyproject/testenv/lib64/python2.7/dist-packages/

like image 523
cdhit Avatar asked Oct 30 '22 10:10

cdhit


1 Answers

This is an old thread, but I just ran into this on a dated Centos box and the fix was to symlink VIRTUAL_ENV/lib64/pythonXX/dist-packages to VIRTUAL_ENV/lib/pythonXX/dist-packages.

If I understand correctly, there was a shortlived quirk (not sure it was a bug) in an older version of virtualenv. You could also manipulate the sys.path but I would rather fix the environment if possible.

like image 77
nod Avatar answered Nov 15 '22 04:11

nod