简体   繁体   中英

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

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.

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

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

Here you go! You need admin privilege to do it. Type sudo python get-pip.py and enter the admin password.

It will automatically install pip-6.1.1 for you.

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.

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.

Instead of using the default version, install a user-specific Python installation with Homebrew .

brew install python

And then you get the pip command properly installed for free!

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