pip install pyquery
过程中出现如下错误:pip install pyquery
Collecting pyquery
Using 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 pyquery
,pyquery
下载成功,而且lxml-4.2.5
也重新被下载。猜测原因可能是因为在下载pyquery的过程中,还需要下载cssselect-1.0.3 lxml-4.2.5
,因为之前已经安装过lxml
,两个文件有冲突,所以导致安装失败。
pip install pyquery
Collecting pyquery
Using 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