[英]Permission denied when installing Tensorflow with pip
When I try to install Tensorflow with pip install tensorflow
, I get this exception: 当我尝试使用pip install tensorflow
,我得到以下异常:
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? 如何安装tensorflow
包?
When I use: sudo pip install tensorflow
I now get this exception: 当我使用: sudo pip install tensorflow
我现在得到这个例外:
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 而不是说拒绝它说操作不被允许
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和Windows的这个问题:
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
: 您可以使用终端中的su
或sudo
以root
身份安装软件包 :
sudo pip install tensorflow
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: 您可以按照以下步骤以管理员身份安装软件包 :
Run This Program As An Administrator
option. 使用“以管理员身份Run This Program As An Administrator
选项以管理员身份运行命令提示符。 pip install tensorflow
运行命令pip install tensorflow
你应该用sudo pip
来运行它
It clearly seems to be a problem of permissions. 它显然似乎是一个权限问题。
If you are using Ubuntu or Liux OS, the try using: 如果您使用的是Ubuntu或Liux OS,请尝试使用:
sudo pip install tensorflow
If you are using Windows then: 如果您使用的是Windows:
Run the Command prompt as Administrator and the run pip install tensorflow
以管理员身份运行命令提示符并运行pip install tensorflow
For better getting rid of such issues in future, Using Anaconda
. 为了更好地摆脱这些问题,使用Anaconda
。
You need to install with administrator permissions. 您需要使用管理员权限进行安装。 This can be done with sudo
command. 这可以使用sudo
命令完成。
I would suggest also specifying the Python interpreter as well as using pip
, to stop the confusion of where pip
should install to. 我建议还指定Python解释器以及使用pip
来阻止pip
应安装到的位置的混淆。 By default there are two versions plus those you may have installed yourself. 默认情况下,有两个版本加上您自己安装的版本。
To install on 2.7 you could use this: 要在2.7上安装,您可以使用:
sudo python -m pip install tensorflow
To install on 3.6 you could use this: 要在3.6上安装,您可以使用:
sudo python36 -m pip install tensorflow
For 3.5 you could use this: 对于3.5你可以使用这个:
sudo python3 -m pip install tensorflow
To tell what the version each Python is you can use which python
要告诉每个Python的版本是什么,你可以使用which python
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.