简体   繁体   English

python:引用不同的pip目录

[英]python : refer to different pip directory

I have a user account (named tamtam) on a remote server, and therefore I do not have permissions to /usr/bin/ . 我在远程服务器上有一个用户帐户(名为tamtam),因此我没有对/usr/bin/权限。

Current situation 现在的情况

$which -a python3
/usr/bin/python3                    #no permission
$which -a pip
/usr/prakt/tamtam/.local/bin/pip   #have permission, "local pip"
/usr/bin/pip                       #no permission, "system pip"

Basically, I am able to install python packages to my local pip but not my system pip. 基本上,我能够将python软件包安装到本地pip,但不能安装到系统pip。 But because my python3 interpreter is linked to the system pip, it can't access the python packages that I installed thru my local pip. 但是因为我的python3解释器链接到系统pip,所以它无法访问通过本地pip安装的python软件包。

What I would like 我想要什么

I would like to install and run my own python packages. 我想安装并运行自己的python软件包。 Can I link my system python3 to my local pip instead of the system pip? 我可以将系统python3链接到本地​​pip而不是系统pip吗? If not, what are some workarounds? 如果没有,有什么解决方法? Thank you. 谢谢。

This will force Python to run that pip : 这将迫使Python运行 pip

python -m /usr/prakt/tamtam/.local/bin/pip install <package>

Then later (I recommend): 然后,稍后(我建议):

$ cd /usr/prakt/tamtam/.local/bin # first change the dir to where your pip is
$ python -m ./pip install virtualenv
$ cd /path/to/prj
$ virtualenv env
$ source env/bin/activate
(env) $ pip install <package>
(env) $ deactivate

Thus the pip you have access to will create ANOTHER pip that is isolated with an environment. 因此, pip可以访问将创造另一个pip是分离的环境。 You should have complete control over that pip and python from there on; 您应该从那里完全控制那个pippython more here . 这里更多。

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

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