4

When I try to install Tensorflow with pip install tensorflow, I get this exception:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 323, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/protobuf-3.5.2-py2.7-nspkg.pth'

What does it mean? How can I install the tensorflow package?

When I use: sudo pip install tensorflow I now get this exception:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/n6/bfff99yn3nnc46h_gh5tc7fm0000gn/T/pip-TI9hQ_-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

Instead of saying denied it says Operation not permitted

Thomas Briggs
  • 119
  • 1
  • 11
  • 1
    Try using virtualenv or if you really have to install it on a system level (not recommended) use `sudo` to install it. – Maximilian Peters Mar 07 '18 at 12:14
  • Possible duplicate of [pip install -r: OSError: \[Errno 13\] Permission denied](https://stackoverflow.com/questions/31512422/pip-install-r-oserror-errno-13-permission-denied) – phd Mar 07 '18 at 22:58

4 Answers4

4

Looks like your user doesn't have the permission to install packages in your system (for all users). Here's how to fix this problem for Linux, macOS and Windows:

Linux / macOS

From your terminal, you can install the package for your user only, like this:

pip install tensorflow --user

OR

You can use su or sudo from your terminal, to install the package as root:

sudo pip install tensorflow

Windows

From the Command Prompt, you can install the package for your user only, like this:

pip install tensorflow --user

OR

You can install the package as Administrator, by following these steps:

  1. Run the Command Prompt as Administrator, using the Run This Program As An Administrator option.
  2. Run the command pip install tensorflow
Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
2

You should run this with sudo pip

Xantium
  • 11,201
  • 10
  • 62
  • 89
Thiên Duy
  • 64
  • 1
  • 7
2

It clearly seems to be a problem of permissions.

If you are using Ubuntu or Liux OS, the try using:

sudo pip install tensorflow

If you are using Windows then:

Run the Command prompt as Administrator and the run pip install tensorflow

For better getting rid of such issues in future, Using Anaconda.

0

You need to install with administrator permissions. This can be done with sudo command.

I would suggest also specifying the Python interpreter as well as using pip, to stop the confusion of where pip should install to. By default there are two versions plus those you may have installed yourself.

To install on 2.7 you could use this:

sudo python -m pip install tensorflow

To install on 3.6 you could use this:

sudo python36 -m pip install tensorflow

For 3.5 you could use this:

sudo python3 -m pip install tensorflow

To tell what the version each Python is you can use which python

Xantium
  • 11,201
  • 10
  • 62
  • 89