为当前用户点安装python软件包 [英] Pip install python package for current user

查看:183
本文介绍了为当前用户点安装python软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我删除了一些与python 2.7相关的文件,现在我疯了.我想使用pip为当前用户而非全局用户安装python软件包.

Recently I delete some files related to python 2.7 and now I'm crazy. I want to use pip to install python package for current user rather global user.

➜  ~ where pip
/usr/local/bin/pip

➜  ~ pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

过去,我可以通过pip install requests轻松安装requests.但是现在我必须sudo pip install requestspip install --user requests.

In the past, I can install requests easily by pip install requests. But now I have to sudo pip install requests or pip install --user requests.

我认为由于pip的位置,我必须在/Library/Python/2.7/....中安装python软件包.如您所见,它需要root权限.我知道venv可以帮助我,但现在我想知道如何为当前用户安装python软件包.

I think because of pip's location I have to install python package within /Library/Python/2.7/..... As you see, it needs root permission. I know venv can help me but now I want to know how to intall python package for current user.

推荐答案

使用pip--user选项:

pip install --user package 

根据 pip的文档:

--user

安装到您平台的Python用户安装目录.通常是Windows上的〜/.local/或%APPDATA%Python. (有关完整详情,请参见Python文档.site.USER_BASE.)

Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%Python on Windows. (See the Python documentation for site.USER_BASE for full details.)

这篇关于为当前用户点安装python软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆