mac上python安装pip,如何在Mac OS X上为python安装pip包?

I'm currently stuck on exercise 46 in Zed Shaw's "Learn Python the Hardway". He says I need to install the following python packages:

He doesn't give the reader any directions on how to properly install the packages and use them. I went to the pip website but the directions were also very vague and kind of unhelpful for a newbie. The installation guide found on https://pip.pypa.io/en/latest/installing.html says to download the get-pip.py file and then run it by typing python get-pip.py in what I presume to be terminal.

When I do that it starts downloading, then says cleaning up.. and then a red error message appears that says:

Exception:

Traceback (most recent call last):"

followed by a bunch of file names before ending with

"OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip

Does anyone know how to correct this? If it helps, the get-pip.py file is in my downloads folder, so I did cd Downloads before running python get-pip.py"

解决方案

The error-message is IMHO pretty clear - you are not allowed to write into the given directory.

The reason for this is that you use the system-provided Python 2.7. While installing pip shouldn't break it, I personally would rather download a Python 2.7 installer, install it, and then do

$ /Library/Frameworks/Python.framework/Versions/2.7/bin/python get-pip.py

This should install pip into this python, and place the pip-executable at the same location as just given

$ /Library/Frameworks/Python.framework/Versions/2.7/bin/pip

If you insist on using the system python, make it "sudo python get-pip.py". But I wouldn't mess with my system python unless forced to.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值