pip: IOError: [Errno 13] Permission denied: '/usr/local/bin/pip'

  • Pip version:1.5.4
  • Python version:2.7.6
  • Operating System:ubuntu 14.04

Description:

How can i solve the following problem:

I was trying to install autograd and scikit-learn, both through pip command. However, both installation failed, with the error OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip'

thus i guess these error may caused by pip, so i test pip with update command 'pip install -U pip ', it replied IOError: [Errno 13] Permission denied: '/usr/local/bin/pip'

I guess pip on my machine is broken? Any advice is pretty appreciate, thanks.

What I’ve run:

The log of running command ‘pip install -U pip’ listed below:

Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.5.4
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
  Can't roll back pip; was not uninstalled
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
    pycompile=self.pycompile,
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 312, in move_wheel_files
    generated.extend(maker.make(spec))
  File "/usr/share/python-wheels/distlib-0.1.8-py2.py3-none-any.whl/distlib/scripts.py", line 311, in make
    self._make_script(entry, filenames, options=options)
  File "/usr/share/python-wheels/distlib-0.1.8-py2.py3-none-any.whl/distlib/scripts.py", line 215, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "/usr/share/python-wheels/distlib-0.1.8-py2.py3-none-any.whl/distlib/scripts.py", line 195, in _write_script
    self._fileop.write_binary_file(outname, script_bytes)
  File "/usr/share/python-wheels/distlib-0.1.8-py2.py3-none-any.whl/distlib/util.py", line 384, in write_binary_file
    with open(path, 'wb') as f:
IOError: [Errno 13] Permission denied: '/usr/local/bin/pip'

Storing debug log for failure in /home/eric/.pip/pip.log

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

You should add the --user option to install without needing root permission.

add --user works! I have tried.

pip install --user <package you want to install>

Also see: https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption-user

Couldn’t we add some helpful message for a user? E.g. something like: “if you don’t have root permissions, use virtualenv instead?”

E.g. in R-lang you get this:

> install.packages('yaml')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("yaml") :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead?  (y/n) y
Would you like to create a personal library
~/R/x86_64-pc-linux-gnu-library/3.0
to install packages into?  (y/n) y

that would definitely help a lot of beginners…

go to super user. after that run ‘pip install -U pip’

Thanks urllib3 installed successfully using pip.