cmd輸入安裝selenium指令:
pip install selenium
1.報錯 Could not find a version that satisfies the requirement selenium (from versions: )
No matching distribution found for selenium
說找不到合適的版本
解決:找了很多資料,其中有個說切換網絡的,我試了一下,果然有用。我連接的移動校園網,后來用手機開了4G熱點,連接后再下載,就沒有這個報錯了。
但是:出現了新的錯誤:
2.報錯:Could not install packages due to an EnvironmentError: [WinError 5] 拒絕訪問。: 'C:\\Program Files\\Python37\\Lib\\site-packages\\selenium'
Consider using the `--user` option or check the permissions.
解決:權限問題,把安裝指令改為:
pip install --user selenium
成功安裝,警告被我忽略了。
安裝驅動geckodriver(驅動用於打開瀏覽器)
下載地址:https://github.com/mozilla/geckodriver/releases
解壓到python文件根目錄。