当前位置: 代码迷 >> 综合 >> Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。
  详细解决方案

Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。

热度:90   发布时间:2023-12-18 03:01:18.0
  • 安装pip install pyquery 过程中出现如下错误:
pip install pyqueryCollecting pyqueryUsing cached https://files.pythonhosted.org/packages/09/c7/ce8c9c37ab8ff8337faad3335c088d60bed4a35a4bed33a64f0e64fbcf29/pyquery-1.4.0-py2.py3-none-any.whl
Collecting lxml>=2.1 (from pyquery)Using cached https://files.pythonhosted.org/packages/b9/55/bcc78c70e8ba30f51b5495eb0e3e949aa06e4a2de55b3de53dc9fa9653fa/lxml-4.2.5-cp36-cp36m-win_amd64.whl
Collecting cssselect>0.7.9 (from pyquery)Using cached https://files.pythonhosted.org/packages/7b/44/25b7283e50585f0b4156960691d951b05d061abf4a714078393e51929b30/cssselect-1.0.3-py2.py3-none-any.whl
Installing collected packages: lxml, cssselect, pyquery
Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'd:\anaconda3\Lib\site-packages\lxml\etree.cp36-win_amd64.pyd'
Consider using the `--user` option or check the permissions.

上面代码中最重要的是这句(第10行)Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'd:\anaconda3\Lib\site-packages\lxml\etree.cp36-win_amd64.pyd',意思是在安装pyquery的过程中由于lxml 中的etree.cp36-win_amd64.pyd 拒绝访问,导致安装失败。

解决办法

最简单的办法是删除lxml 文件夹,然后重新运行pip install pyquerypyquery下载成功,而且lxml-4.2.5 也重新被下载。猜测原因可能是因为在下载pyquery的过程中,还需要下载cssselect-1.0.3 lxml-4.2.5 ,因为之前已经安装过lxml,两个文件有冲突,所以导致安装失败。

pip install pyqueryCollecting pyqueryUsing cached https://files.pythonhosted.org/packages/09/c7/ce8c9c37ab8ff8337faad3335c088d60bed4a35a4bed33a64f0e64fbcf29/pyquery-1.4.0-py2.py3-none-any.whl
Collecting lxml>=2.1 (from pyquery)Using cached https://files.pythonhosted.org/packages/b9/55/bcc78c70e8ba30f51b5495eb0e3e949aa06e4a2de55b3de53dc9fa9653fa/lxml-4.2.5-cp36-cp36m-win_amd64.whl
Collecting cssselect>0.7.9 (from pyquery)Using cached https://files.pythonhosted.org/packages/7b/44/25b7283e50585f0b4156960691d951b05d061abf4a714078393e51929b30/cssselect-1.0.3-py2.py3-none-any.whl
Installing collected packages: lxml, cssselect, pyquery
Successfully installed cssselect-1.0.3 lxml-4.2.5 pyquery-1.4.0
  相关解决方案