12

I am trying to install TensorFlow by Anaconda(My Python is 3.5.2 edition).

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:

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?

1
  • Doing a pip install in a bash-like environment seems to prevent this type of problem. I've only experienced it with tensorflow. Commented Apr 24, 2019 at 8:58

9 Answers 9

29

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. Hence I got permission denied. All I did was shut down every process anaconda, jupyter etc and ran:

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

Open your cmd as an administrator and do not activate tensorflow. Just simply fire commands from your cmd. For eg: C:\\> pip install --ignore-installed tensorflow (your directory may vary) should be fine. Let me know if you get stuck.

Sign up to request clarification or add additional context in comments.

4 Comments

After trying all the answers on internet, this worked for me. Thanks for point this out.
indeed some process locked the file, i can't delete the file by myself.
I don't think you need to delete anything.. Just stop the process which unlocks the file and you should be good to go
I had an ipython instance running which I had forgotten about, closing it freed up the resource so I could install. Thanks for pointing me in the right direction
2

Run the cmd console as adminstrator, then execute you installation.

You can key cmd in run or Cortana, then right click the console and select run as adminstrator.

Comments

1

I had the same problem on several Windows machines (W7, W8.1 and W10). At last I solved the problem in the same way in all of them:

  1. Uninstall Anaconda
  2. Download Anaconda3-4.2.0 from Anaconda Installer Archive. This version of Anaconda includes 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
  3. Install Anaconda3-4.2.0 on a different drive than the Windows drive, for example in 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:
  5. Create a environment named tensorflow by invoking the following command:

    conda create -n tensorflow python=3.5

  6. Activate the conda environment by issuing the following command:

    activate tensorflow

  7. Install 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:

    conda install spyder

    conda install jupyter

  9. After that you can check if all is correct by invoking python and trying the next program:

    import tensorflow as tf
    hail = tf.constant('Hello World')
    session = tf.Session()
    print(session.run(hail))
    
  10. Now you can check if Spyder works. Exit from Python, invoke Spyder from Anaconda prompt and try de program.

  11. If you have any problem with iPython, install it on the tensorflow enviroment.

    conda install ipython

  12. If you want to update spyder write the following command:

    conda update spyder

Remember to launch Spyder from the Anaconda prompt after you have activated the tensorflow enviroment.

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.

2 Comments

I had the same problem and only followed steps 1 and 2. Then without running Anaconda Prompt under admin (I don't have permission to do so), I followed the instructions on tensorflow.org/install/install_windows, and it worked for me.
I think you do not want to use Spyder because I was unable to use Spyder by installing with PIP. Do you use Spyder?
1

I had permission denied problem on windows but this worked for me:

  1. right click on cmd or git console > run as administrator
  2. pip install tensorflow

Comments

1

Maybe because there are other processes using tensorflow. Try to close these processes and then install or update tensorflow.

Comments

0

I had the same error and fixed it by running conda update --all first.

BUt be careful with conda update: (https://github.com/ContinuumIO/anaconda-issues/issues/830) Updating packages

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. (Replacing activate.bat with the original one just works fine.)

Comments

0

I had the same error for python 3.6, ran cmd through admin mode, worked like a charm.

Comments

0

I had a file locked up from a crashed Jupyter run. Rebooted and reinstalled as Adm. All good.

Comments

-3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.