Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied when installing Tensorflow with pip

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

like image 725
Thomas Briggs Avatar asked Jan 29 '23 13:01

Thomas Briggs


2 Answers

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
like image 104
Ronan Boiteau Avatar answered Jan 31 '23 18:01

Ronan Boiteau


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.

like image 29
Amazing Things Around You Avatar answered Jan 31 '23 18:01

Amazing Things Around You