简体   繁体   English

在虚拟环境中安装 python 站点包

[英]Installing python site-packages in virtual environment

Well, I have already installed python and some site-packages (including pandas) but I have learned about virtual enviroments and want to use it.好吧,我已经安装了 python 和一些站点包(包括 Pandas),但我已经了解了虚拟环境并想使用它。 I want to install pandas to my VE.我想将 Pandas 安装到我的 VE。 First of all, I did this:首先,我是这样做的:

(python_venv) denis@denis-laptop:~$ pip3 install pandas

And got:并得到:

...
PermissionError: [Errno 13] Отказано в доступе: '/environments/python_venv/lib/python3.7/site-packages/six.py'

So, I did:所以我做了:

(python_venv) denis@denis-laptop:~$ pip3 install --user pandas

Got:得到了:

...
Installing collected packages: numpy, six, python-dateutil, pytz, pandas
Successfully installed numpy-1.15.4 pandas-0.23.4 python-dateutil-2.7.5 pytz-2018.7 six-1.11.0

But I haven't got pandas in pip3 list:但是我在 pip3 列表中没有熊猫:

(python_venv) denis@denis-laptop:~$ pip3 list --format=columns
Package       Version
------------- -------
pip           9.0.1  
pkg-resources 0.0.0  
setuptools    39.0.1 

What should I do?我该怎么办? I have Ubuntu 18.04.我有 Ubuntu 18.04。

Looks like a permission issue: you should be able to write files in your virtual environment as your user and the --user option should omitted.看起来像是权限问题:您应该能够以用户身份在虚拟环境中写入文件,并且应该省略--user选项。 I suggest you change the ownership of the virtualenv as follows:我建议您按如下方式更改 virtualenv 的所有权:

chown -R $(whoami):$(whoami) /environments/python_venv

and then try the first pip install pandas again然后再次尝试第一个pip install pandas

Considering Successfully installed numpy-1.15.4 pandas-0.23.4 you probably have it installed.考虑到已Successfully installed numpy-1.15.4 pandas-0.23.4您可能已经安装了它。 Did you try running pip list --user ?您是否尝试运行pip list --user

You have installed pandas to user install folder and possibly this does not show in the general pip list command.您已将 pandas 安装到用户安装文件夹,这可能不会显示在常规pip list命令中。 You can notice that the output of pip list is missing not only pandas but actually all the packages you installed with pip3 install --user pandas .您会注意到pip list的输出不仅缺少pandas而且实际上缺少您使用pip3 install --user pandas安装的所有软件包。 Btw., there is no need to specify --format=columns , as it's the default.顺便说一句,没有必要指定--format=columns ,因为它是默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM