简体   繁体   English

安装Tensorflow时权限被拒绝

[英]Permission denied when installing Tensorflow

I am trying to install TensorFlow by Anaconda(My Python is 3.5.2 edition). 我正在尝试安装Anaconda的TensorFlow(我的Python是3.5.2版)。

When I run: 当我跑步时:

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.1-cp35-cp35m-win_amd64.whl 

According to the guide in Tensorflow.org, the following tips emerge: 根据Tensorflow.org中的指南,出现以下提示:

Exception:
Traceback (most recent call last):
File "C:\Users\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
File "C:\Users\Anaconda3\lib\site-packages\pip\commands\install.py", line 317, in run
prefix=options.prefix_path,
File "C:Anaconda3\lib\site-packages\pip\req\req_set.py", line 742, in install
**kwargs
File "C:\Users\Anaconda3\lib\site-packages\pip\req\req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Users\Anaconda3\lib\site-packages\pip\req\req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "C:\Users\Anaconda3\lib\site-packages\pip\wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "C:\Users\Anaconda3\lib\site-packages\pip\wheel.py", line 324, in clobber
shutil.copyfile(srcfile, destfile)
File "C:\Users\Anaconda3\lib\shutil.py", line 115, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Anaconda3\\Lib\\site-packages\\numpy\\core\\multiarray.cp35-win_amd64.pyd'

I don't know what causes this error. 我不知道是什么原因导致此错误。 Can someone help me with that? 有人可以帮我吗?

Might be late but I got the exact same error and this is what happened. 可能迟到了,但是我得到了完全相同的错误,这就是发生的情况。 My issue was that there was some file that was being used inside numpy that was locked by anaconda(or some other process) I guess and tensorflow needed that file. 我的问题是,在numpy中使用了某个文件,该文件被anaconda(或其他进程)锁定了,我猜是和tensorflow需要该文件。 Hence I got permission denied. 因此,我被拒绝了。 All I did was shut down every process anaconda, jupyter etc and ran: 我所做的就是关闭anaconda,jupyter等的每个进程并运行:

1) conda update --all
2) pip install --ignore-installed tensorflow

Open your cmd as an administrator and do not activate tensorflow. 以管理员身份打开您的cmd,请勿激活tensorflow。 Just simply fire commands from your cmd. 只需从您的cmd发出命令即可。 For eg: C:\\\\> pip install --ignore-installed tensorflow (your directory may vary) should be fine. 例如: C:\\\\> pip install --ignore-installed tensorflow (您的目录可能有所不同)应该没问题。 Let me know if you get stuck. 让我知道您是否被卡住。

Run the cmd console as adminstrator, then execute you installation. 以管理员身份运行cmd控制台,然后执行安装。

You can key cmd in run or Cortana, then right click the console and select run as adminstrator. 您可以在run或Cortana中键入cmd,然后右键单击控制台,然后选择以管理员身份运行。

I had the same problem on several Windows machines (W7, W8.1 and W10). 在几台Windows机器(W7,W8.1和W10)上,我遇到了同样的问题。 At last I solved the problem in the same way in all of them: 最后,我以相同的方式解决了所有问题:

  1. Uninstall Anaconda 卸载Anaconda
  2. Download Anaconda3-4.2.0 from Anaconda Installer Archive . Anaconda安装程序档案中下载Anaconda3-4.2.0。 This version of Anaconda includes Python 3.5.2. 此版本的Anaconda包括Python 3.5.2。 TensorFlow only supports version 3.5.x of Python on Windows.Although you can create an environment with version 3.5 of Python, I recommend installing Anaconda 4.2.0 TensorFlow仅在Windows上支持Python 3.5.x版本。尽管您可以使用Python 3.5版本创建环境,但我建议安装Anaconda 4.2.0
  3. Install Anaconda3-4.2.0 on a different drive than the Windows drive, for example in D:\\Programdata\\Anaconda3. 将Anaconda3-4.2.0安装在与Windows驱动器不同的驱动器上,例如,在D:\\ Programdata \\ Anaconda3中。 Although installing on another drive is no longer necessary, better to select to install for all users. 尽管不再需要在其他驱动器上进行安装,但最好为所有用户选择安装。
  4. Open an Anaconda Promp with administrator privileges and: 使用管理员权限打开Anaconda Promp,并:
  5. Create a environment named tensorflow by invoking the following command: 通过调用以下命令来创建一个名为tensorflow的环境:

    conda create -n tensorflow python=3.5

  6. Activate the conda environment by issuing the following command: 通过发出以下命令来激活conda环境:

    activate tensorflow

  7. Install TensorFlow: 安装TensorFlow:

    conda install -c conda-forge tensorflow

  8. Install Jupyter and Spyder at least, but surely you will need to install scipy too for example: 至少安装Jupyter和Spyder,但是当然您也需要安装scipy,例如:

    conda install spyder

    conda install jupyter

  9. After that you can check if all is correct by invoking python and trying the next program: 之后,您可以通过调用python并尝试下一个程序来检查所有设置是否正确:

     import tensorflow as tf hail = tf.constant('Hello World') session = tf.Session() print(session.run(hail)) 
  10. Now you can check if Spyder works. 现在,您可以检查Spyder是否有效。 Exit from Python, invoke Spyder from Anaconda prompt and try de program. 从Python退出, 从Anaconda提示符处调用Spyder并尝试进行编程。

  11. If you have any problem with iPython, install it on the tensorflow enviroment. 如果iPython有任何问题,请将其安装在tensorflow环境中。

    conda install ipython

  12. If you want to update spyder write the following command: 如果要更新spyder,请编写以下命令:

    conda update spyder

Remember to launch Spyder from the Anaconda prompt after you have activated the tensorflow enviroment. 记住在激活tensorflow环境后从Anaconda提示符启动Spyder。

I hope it works for you. 我希望这个对你有用。

Edited: TensorFlow, since version 1.2.0, is compatible with Python 3.6, so you can already install the latest version of Anaconda (4.4.0 | Release Date: May 31, 2017), which incorporates Python 3.6. 编辑:TensorFlow,自1.2.0版开始,与Python 3.6兼容,因此您已经可以安装最新版本的Anaconda(4.4.0 |发布日期:2017年5月31日),该版本包含Python 3.6。

Maybe because there are other processes using tensorflow. 可能是因为还有其他使用张量流的过程。 Try to close these processes and then install or update tensorflow. 尝试关闭这些过程,然后安装或更新tensorflow。

I had the same error and fixed it by running conda update --all first. 我遇到了同样的错误,并先运行conda update --all修复它-全部都是。

BUt be careful with conda update: ( https://github.com/ContinuumIO/anaconda-issues/issues/830 ) Updating packages 小心使用conda更新:( https://github.com/ContinuumIO/anaconda-issues/issues/830 )更新软件包

conda:        4.0.5-py35_0       --> 4.1.1-py35_0
conda-env:    2.4.5-py35_0       --> 2.5.0-py35_0
matplotlib:   1.5.1-np110py35_0  --> 1.5.1-np111py35_0
mkl:          11.3.1-0           --> 11.3.3-1
mkl-service:  1.1.2-py35_0       --> 1.1.2-py35_1
numexpr:      2.5-np110py35_0    --> 2.5.2-np111py35_1
numpy:        1.10.4-py35_0      --> 1.11.0-py35_1
pandas:       0.18.0-np110py35_0 --> 0.18.1-np111py35_0
scikit-learn: 0.17.1-np110py35_0 --> 0.17.1-np111py35_1
scipy:        0.17.0-np110py35_0 --> 0.17.0-np111py35_4

will break Scripts/activate.bat under Windows if the install path contains spaces. 如果安装路径包含空格,将在Windows下破坏Scripts / activate.bat。 (Replacing activate.bat with the original one just works fine.) (用原始的替换activate.bat很好用。)

我在python 3.6上遇到了相同的错误,通过admin模式运行了cmd,效果非常好。

I had permission denied problem on windows but this worked for me: 我在Windows上有权限被拒绝的问题,但这对我有用:

  1. right click on cmd or git console > run as administrator 右键单击cmd或git控制台>以管理员身份运行
  2. pip install tensorflow 点安装tensorflow

I had a file locked up from a crashed Jupyter run. 我有一个文件因Jupyter运行崩溃而被锁定。 Rebooted and reinstalled as Adm. All good. 重新启动并重新安装为Adm,一切都很好。

I solved problem by below command 我通过以下命令解决了问题

pip install  --upgrade
https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.1-cp35-cp35m-win_amd64.whl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM