You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac下如何通过命令行将chromedriver放入系统PATH路径?

Got it, let's fix this quickly! The issue is that your system can't find chromedriver when Selenium runs because it's not in a directory included in your system's PATH. Below are step-by-step command line solutions for different operating systems to move chromedriver to a valid PATH directory:

Windows
  • First, open Command Prompt or PowerShell as Administrator (right-click the app and select "Run as administrator" to avoid permission errors).
  • Replace YourUsername with your actual Windows username in the command below, then run it:
    copy "C:\Users\YourUsername\Downloads\chromedriver.exe" "C:\Windows\System32\"
    
    For example, if your username is "Alice", the command becomes:
    copy "C:\Users\Alice\Downloads\chromedriver.exe" "C:\Windows\System32\"
    
  • Close and reopen your Python terminal/IDE, then run your script again—Selenium should now locate chromedriver automatically.
macOS
  • Launch the Terminal app.
  • First, ensure the target directory exists (it usually does, but just in case):
    sudo mkdir -p /usr/local/bin
    
  • Copy chromedriver to the directory that's in your system PATH:
    sudo cp ~/Downloads/chromedriver /usr/local/bin/
    
  • Grant executable permissions to the file (this ensures it runs properly):
    sudo chmod +x /usr/local/bin/chromedriver
    
  • Refresh your PATH settings or restart the Terminal, then test your Python script. To refresh PATH immediately, run:
    source ~/.zshrc
    
    (If you use Bash instead of Zsh, run source ~/.bash_profile.)
Linux
  • Open your Terminal.
  • Copy chromedriver to a standard PATH directory like /usr/local/bin:
    sudo cp ~/Downloads/chromedriver /usr/local/bin/
    
  • Add executable permissions to the file:
    sudo chmod +x /usr/local/bin/chromedriver
    
  • Restart the Terminal or refresh your PATH, then run your Python code again.

内容的提问来源于stack exchange,提问作者The Walrus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:47:44