python pdb pip安装_为什么我的pip安装需要python -m install --user?

I am running this inside a virtual environment.

When I type:

pip install django

I get:

ERROR: Could not install packages due to an EnvironmentError: [Errno

13] Permission denied: /home/ENV/env/lib/python3.5/site-packages/pytz

Consider using the --user option or check the permissions.

For it to work I actually need to input:

python -m pip install --user django

Why?

解决方案

Let's break the two statements you added to your first command:

python -m install --user django

python -m: Allows modules to be located using the Python module namespace for execution as scripts. The motivating examples were standard library modules such as pdb and profile. See PEP 338

--user : By default pip installs Python packages to system directories which requires root privileges, to avoid using sudo pip install (which is not recommended by the way) use this flag to make pip install packages in your home directory instead, which doesn't require any special privileges.

As a side note, if you have multiple versions of Python installed, keeping track of which Python version version pip is bound to can be a PITA, hence python -m in this case you're sure that it's the pip bound to the Python called which will be executed.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值