简体   繁体   English

Mavericks Python 3.4 pip安装错误

[英]Mavericks Python 3.4 pip install error

Trying to install pip and I get this error following https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python 尝试安装pip,我在https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python之后收到此错误

Sumners-MacBook-Pro:Downloads Sumner$ python get-pip.py
Downloading/unpacking pip
  Downloading pip-1.5.4-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/var/folders/l6/0vw_83pn3kq52x2wjhkmns2r0000gn/T/tmpAovvNy/pip.zip/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/var/folders/l6/0vw_83pn3kq52x2wjhkmns2r0000gn/T/tmpAovvNy/pip.zip/pip/commands/install.py", line 279, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/var/folders/l6/0vw_83pn3kq52x2wjhkmns2r0000gn/T/tmpAovvNy/pip.zip/pip/req.py", line 1380, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/var/folders/l6/0vw_83pn3kq52x2wjhkmns2r0000gn/T/tmpAovvNy/pip.zip/pip/req.py", line 664, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/var/folders/l6/0vw_83pn3kq52x2wjhkmns2r0000gn/T/tmpAovvNy/pip.zip/pip/req.py", line 894, in move_wheel_files
    pycompile=self.pycompile,
  File "/var/folders/l6/0vw_83pn3kq52x2wjhkmns2r0000gn/T/tmpAovvNy/pip.zip/pip/wheel.py", line 202, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/var/folders/l6/0vw_83pn3kq52x2wjhkmns2r0000gn/T/tmpAovvNy/pip.zip/pip/wheel.py", line 189, in clobber
    os.makedirs(destsubdir)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'

Storing debug log for failure in /Users/Sumner/Library/Logs/pip.log

As I cannot comment due to my lack of 50 reputation, I will 'comment' in an answer. 由于我缺乏50个声誉,我无法发表评论,我将在答案中“发表评论”。

Although you may be admin, you still have to type sudo before you do anything... To check if your account has admin privileges, type sudo bash in your terminal, and if it says myusername is not in the sudoers file. This incident will be reported. 虽然您可能是管理员,但在执行任何操作之前仍需要键入sudo ...要检查您的帐户是否具有管理员权限,请在终端中键入sudo bash ,如果它表示myusername is not in the sudoers file. This incident will be reported. myusername is not in the sudoers file. This incident will be reported. , then you aren't an admin. ,那么你不是管理员。

Here is a short demonstration of the above: 以下是上述简短演示:

ajs-iMac-5:~ aj8uppal$ sudo bash
Password:
bash-3.2# 
bash-3.2# exit
ajs-iMac-5:~ aj8uppal$ pip install colorama
Downloading/unpacking colorama
  Downloading colorama-0.2.7.tar.gz
  Running setup.py (path:/private/var/folders/f7/r3hxg4tx3859tjpb0n_q9hnw0000gp/T/pip_build_aj8uppal/colorama/setup.py) egg_info for package colorama

Installing collected packages: colorama
  Running setup.py install for colorama
    error: could not create '/Library/Python/2.7/site-packages/colorama': Permission denied
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/f7/r3hxg4tx3859tjpb0n_q9hnw0000gp/T/pip_build_aj8uppal/colorama/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/f7/r3hxg4tx3859tjpb0n_q9hnw0000gp/T/pip-geh1_f-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib

creating build/lib/colorama

copying colorama/__init__.py -> build/lib/colorama

copying colorama/ansi.py -> build/lib/colorama

copying colorama/ansitowin32.py -> build/lib/colorama

copying colorama/initialise.py -> build/lib/colorama

copying colorama/win32.py -> build/lib/colorama

copying colorama/winterm.py -> build/lib/colorama

running install_lib

creating /Library/Python/2.7/site-packages/colorama

THE ERROR: error: could not create '/Library/Python/2.7/site-packages/colorama': Permission denied 错误:错误:无法创建'/Library/Python/2.7/site-packages/colorama':权限被拒绝

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/f7/r3hxg4tx3859tjpb0n_q9hnw0000gp/T/pip_build_aj8uppal/colorama/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/f7/r3hxg4tx3859tjpb0n_q9hnw0000gp/T/pip-geh1_f-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/f7/r3hxg4tx3859tjpb0n_q9hnw0000gp/T/pip_build_aj8uppal/colorama
Storing debug log for failure in /var/folders/f7/r3hxg4tx3859tjpb0n_q9hnw0000gp/T/tmptJWePV
ajs-iMac-5:~ aj8uppal$ sudo pip install colorama
Downloading/unpacking colorama
  Downloading colorama-0.2.7.tar.gz
  Running setup.py (path:/private/tmp/pip_build_root/colorama/setup.py) egg_info for package colorama

Installing collected packages: colorama
  Running setup.py install for colorama

Successfully installed colorama
Cleaning up...
ajs-iMac-5:~ aj8uppal$ 

Or you could combine the first two steps and head into the third one, and if it raises an error when you type in sudo , then you aren't an admin. 或者你可以结合前两个步骤并进入第三个步骤,如果它在你输入sudo时引发错误,那么你不是管理员。

Here you go! 干得好! You need admin privilege to do it. 您需要管理员权限才能执行此操作。 Type sudo python get-pip.py and enter the admin password. 输入sudo python get-pip.py并输入管理员密码。

It will automatically install pip-6.1.1 for you. 它将自动为您安装pip-6.1.1。

This appears to be because the default version of Python, shipped with the OSX operating system, requires sudo permissions to run in a few places. 这似乎是因为OSX操作系统附带的默认版本的Python需要sudo权限才能在几个地方运行。

In general you probably shouldn't be developing with the operating system version of python, and I personally prefer never to sudo install anything that doesn't obviously need root access. 一般来说,您可能不应该使用python的操作系统版本进行开发,我个人更喜欢从不sudo安装任何显然不需要root访问权限的东西。

Instead of using the default version, install a user-specific Python installation with Homebrew . 不使用默认版本,而是使用Homebrew安装特定于用户的Python安装。

brew install python

And then you get the pip command properly installed for free! 然后你就可以免费正确安装pip命令了!

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

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