Pip未安装在virtualenv中

时间:2018-08-28 22:05:53

标签: python linux pip

我已经安装了不带系统软件包的pip。

which pip
/home/pdaly/envs/py3/bin/pip

which python
/home/pdaly/envs/py3/bin/python

当我通过pip在virtualenv内安装时,尽管其中有pip指向env,但似乎正在使用系统pip而不是虚拟env pip。我收到以下错误

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pandas-0.23.4.dist-info'

我该如何解决?

注意:有20-30个人都在使用这台机器将软件包直接安装到系统python ...

(py3) pdaly@gpu01:~$ /home/pdaly/envs/py3/bin/python -c "import os, sys; print(os.linesep.join(sys.path))"
/home/pdaly/<private repo 1>/lib
/home/pdaly/<private repo 2>
/home/pdaly/<private repo 3>
/home/pdaly/envs/py3/lib/python35.zip
/home/pdaly/envs/py3/lib/python3.5
/home/pdaly/envs/py3/lib/python3.5/plat-x86_64-linux-gnu
/home/pdaly/envs/py3/lib/python3.5/lib-dynload
/usr/lib/python3.5
/usr/lib/python3.5/plat-x86_64-linux-gnu
/home/pdaly/envs/py3/lib/python3.5/site-packages

(py3) pdaly@gpu01:~$ echo $PYTHONPATH
/home/pdaly/<private repo 1>/lib/:/home/pdaly/<private repo 2>/:/home/pdaly/<private repo 3>/

1 个答案:

答案 0 :(得分:-1)

正如其中一条注释中提到的那样(kudos @mydaemon),您正在使用的venv是python3环境,它与python2 libs / scripts不兼容。此外,如果您未激活环境,那么所有python脚本/工具都将继续在系统python (在本例中为python2.7)上运行。

要使其以python3的身份运行,只需:编辑:新信息表明此环境确实是已激活的python3环境,因此将无法工作)。

. ${HOME}/envs/py3/bin/activate
pip install panda

要使用python2:

virtualenv --python=python2.7 ${HOME}/envs/py2
. ${HOME}/envs/py2/bin/activate
pip install panda

编辑Pandas on PyPi是python 2.x库,不适用于python3上的pip。 Pandas website建议通过anaconda

安装