[英]How to fix error when downloading pyPDF2 on Python 3.6.0?
I am trying to install the pyPDF2
package on Python 3.6.0
. 我正在尝试在
Python 3.6.0
上安装pyPDF2
软件包。 When I open the Command Prompt and type python -m pip install pyPDF2
I receive the following error: 当我打开命令提示符并键入
python -m pip install pyPDF2
,出现以下错误:
Successfully built pyPDF2
Installing collected packages: pyPDF2
成功构建
pyPDF2
安装收集的软件包: 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.错误:由于环境错误而无法安装软件包:[WinError 5]访问被拒绝:'C:\\ Program Files \\ Python36 \\ Lib \\ site-packages \\ PyPDF2'考虑使用
--user
选项或检查权限。
Previously, I experienced a similar issue with installing the pip
library. 以前,我在安装
pip
库时遇到过类似的问题。 I had to receive administrative rights from another user before successfully downloading pip
. 在成功下载
pip
之前,我必须从其他用户那里获得管理权限。
I am using Windows 10 OS. 我正在使用Windows 10操作系统。
There are a number of options: 有很多选项:
Install packages in your user directory using pip --user
( answer of PoorProgrammer) 使用
pip --user
在您的用户目录中安装软件包(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) 运行蟒蛇/ PIP管理员身份( 答案 SıddıkACIL的)
This is only useful if you have administrative rights. 仅在您具有管理权限时才有用。
Install Python in a non-protected directory (eg C:\\Python\\3.6
) instead of in C:\\Program Files
. 将Python安装在不受保护的目录(例如
C:\\Python\\3.6
)中,而不是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 (eg using python -m pip install --users virtualenv
). 这也没有管理员权限,但您需要先安装
virtualenv
(例如,使用python -m pip install --users virtualenv
)。
To create a virtual environment for Python 3.6 and install the package in it: 要为Python 3.6创建虚拟环境并在其中安装软件包,请执行以下操作:
py -3.6 -m virtualenv --python=3.6 my_virtual_environent
my_virtual_environent\Scripts\activate
python -m pip install pyPDF2
以管理员身份打开cmd
以获得更高的访问权限,然后再次运行Python
pip
安装脚本。
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: 我假设您不想每次都必须抬高
cmd
因此以下各项应能起作用:
python -m pip install --user pyPDF2
If you want to see the location, it should be at %APPDATA%\\Python
since you are using windows. 如果要查看位置,则由于使用Windows,因此它应该位于
%APPDATA%\\Python
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.