'virtualenv''pip install sqlalchemy'但'pip list'无法看到 [英] 'virtualenv' 'pip install sqlalchemy' but 'pip list' can not see
问题描述
我学会了安装python的虚拟环境.
I learned to install a virtual environment of python.
似乎我不太熟悉一些基本的点子常识.
It seems I am not quite familiar some basic pip common sense.
也就是说,
在virtualenv中,
In the virtualenv,
virtualenv test
然后我有一个名为test的虚拟环境.
then I have a virtual environment which name is test.
然后我通过
source ./test/bin/activate
然后我进入虚拟环境
首先,我运行pip list检查软件包
firstly I run pip list to check the packages
pip list
然后我得到了"pip"和设置工具"
then I got 'pip' and 'setup tools'
然后我安装'sqlalchemy'
then I install 'sqlalchemy'
pip install sqlalchemy
我得到了信息成功安装了sqlachemy" 但是当我通过以下方式检查已安装的软件包时:
I got the information 'successfully installed sqlachemy' but when I check the installed packages by
pip list
我仍然只有'pip'和'setuptools'而没有'sqlalchemy'.
I still got only 'pip' and 'setuptools' without 'sqlalchemy'.
我想知道为什么会这样.
I am wondering why this happened.
"sqlalchemy"不是python软件包之一吗?
Is the 'sqlalchemy' not one of the python packages?
我已经检查了'./test/lib64/python2.7/dist-packages/'
And I have checked the './test/lib64/python2.7/dist-packages/'
我看到该目录下的'sqlalchemy'文件夹.
I saw the 'sqlalchemy' folder right under that directory.
有人告诉我为什么吗?
谢谢.
顺便说一句,我检查了'sys.path'变量,发现该值等于
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
但是实际上,'sqlalchemy'安装在目录/home/worker/pyproject/testenv/lib64/python2.7/dist-packages/
But actually, the 'sqlalchemy' is installed in the directory /home/worker/pyproject/testenv/lib64/python2.7/dist-packages/
为什么"sys.path"不包含此内容
/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/
推荐答案
这是一个旧线程,但是我只是在一个过时的Centos机器上遇到了这个问题,解决方法是将VIRTUAL_ENV/lib64/pythonXX/dist-packages符号链接到VIRTUAL_ENV/lib/pythonXX/dist-packages.
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.
如果我理解正确,则在较旧版本的virtualenv中存在一个短暂的怪癖(不确定是错误).您也可以操纵sys.path,但我更愿意修复环境.
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.
这篇关于'virtualenv''pip install sqlalchemy'但'pip list'无法看到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!