Reputation: 3
I am trying to install the pyPDF2
package on Python 3.6.0
. When I open the Command Prompt and type python -m pip install pyPDF2
I receive the following error:
Successfully built pyPDF2
Installing collected packages: pyPDF2
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\Program Files\Python36\Lib\site-packages\PyPDF2' Consider using the
--user
option or check the permissions.
Previously, I experienced a similar issue with installing the pip
library. I had to receive administrative rights from another user before successfully downloading pip
.
I am using Windows 10 OS.
Upvotes: 0
Views: 1578
Reputation: 5093
There are a number of options:
Install packages in your user directory using pip --user
(answer of PoorProgrammer)
This is also the solution provided in the error message itself, and should always work.
Run the python/pip as administrator (answer of Sıddık Açıl)
This is only useful if you have administrative rights.
Install Python in a non-protected directory (e.g. C:\Python\3.6
) instead of in C:\Program Files
.
This should work as long as you're allowed to install software on the computer. Once installed, you can install additional packages without administrative rights.
Install packages in a virtual environment.
This also works without administrative rights, but you need to install virtualenv
once first (e.g. using python -m pip install --users virtualenv
).
To create a virtual environment for Python 3.6 and install the package in it:
py -3.6 -m virtualenv --python=3.6 my_virtual_environent
my_virtual_environent\Scripts\activate
python -m pip install pyPDF2
Upvotes: 2
Reputation: 967
Open cmd
as an administrator to get elevated access and run your Python
pip
install script again.
Upvotes: 1
Reputation: 507
You can install it locally on your user as well. I assume that you don't want to have to go and get your cmd
elevated every time so the following should work:
python -m pip install --user pyPDF2
If you want to see the location, it should be at %APPDATA%\Python
since you are using windows.
Upvotes: 1