- 安裝
過程中出現如下錯誤: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