简体   繁体   中英

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/ .

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. 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.

What I would like

I would like to install and run my own python packages. Can I link my system python3 to my local pip instead of the system pip? If not, what are some workarounds? Thank you.

This will force Python to run that 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. You should have complete control over that pip and python from there on; more here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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