There might be instances when you keep getting an error βCould not install packages due to an EnvironmentError: [Errno 13] Permission deniedβ when you pip install. This error comes up because of missing privilege to the directory in which pip is trying to write files.
Just type the command you want execute with the user permission, if you don't want to change the permission:
pip3 install --upgrade tensorflow-gpu --user
Run the same command using --user
.
just change the access permission, where the particular package is going to install.
In my case windows10:
I found that if I run CMD as Administrator and run the command, I can install it without a problem. Try it and give me some feedback.
I was upgrading tensorflow to 1.4.0 & was hitting my head on wall as this error was not solving, but finally solved it. Guess what?
One of my python script was running, and it was using tensorflow ππ. Package installed successfully after closing it. π
I used this command and it worked:
python -m pip install --user --upgrade pip
Oh my. There are so many bad answers here. Well meaning but misleading. I am usually fine with dealing with permissions on Mac/Linux. Windows is new to me these days. This is the problem I had.
activate
my virtualenv - failed. Needs Scope to run powershell. Windows is helpful and tell you exactly the command you need to run to allow .ps to run. Sort of like chmod
but with execution scope
which I think is good....site-packages/
In my case I suspect it's OneDrive or some permission inheritence.The ideal way forward is to check permissions. This is hard but you are a Python developer are you not! First check your own user.
whoami
e.g. mycomputer\vangelGet-Acl <path which is an issue>
whoami
user explicity with full permissions. then applied to all objects.Dont do these without verifying the below steps. Read the message carefully.
By no means it is the solution for all permissions issues that may affect you. I can only provide guidance on how to troubleshoot and hopefully you resolve.
setting --user
flag is not necessary anywhere, if it works good for you. But you still do not know what went wrong.
More steps:
Try removing a package and installing it.
pip uninstall requests
pip install requests
This works, yet I get permission issue for a specific package.
Turns out, Windows gives permission error when the file is locked by a process. Python reports it as [Winerror 5]
and I could not easily find that documentation reference anyway. lets test this theory.
I find the exact file that gets permission error. Hit delete. Sure enough Windows window
prompt that its open in python
Of course it is.
I hit end task
on all python It has worked since 1996. But I waited a few seconds just in case some process is launching python. Checked Task manager
all good.
Having failed 20 times in getting pip to install the specific azureml package I was feeling pretty sure this resolved it.
I ran my pip install and it installed perfectly fine.
Moral of the story: Understand what you are doing before copy pasting from Stackoverflow. All the best.
p.s. Please stop installing Python or its packages as administrator. We are past that since 2006
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With