我曾尝试在 Ubuntu 18.04LTS 中添加 chrome 驱动程序的路径。
它位于
/home/<usr>/Documents/Python/chromedriver
在我的笔记本电脑里
有人可以帮我解决这个问题吗?
提前致谢。
答案1
下载并解压后Chrome 驱动程序你有三个选择。
A)将文件保存在已经存在的目录中
PATH
B)将文件保存在自定义位置并将其添加到
PATH
C)将文件保存在自定义位置,并在现有目录中创建该文件的符号链接
PATH
对于以下示例,我们假设提取的文件位于~/Downloads
示例 A)
// Move file to a directory that's already in PATH
sudo mv ~/Downloads/chromedriver /usr/local/bin
// Make file executable
sudo chmod +x /usr/local/bin/chromedriver
示例至 B)
// Move file to a directory that's not in PATH
mv ~/Downloads/chromedriver ~/Documents/Python/ChromeDriver/
// Make file executable
chmod +x ~/Documents/Python/ChromeDriver/chromedriver
// Add directory to PATH
echo 'export PATH="$HOME/Documents/Python/ChromeDriver:$PATH"' >> ~/.profile
source ~/.profile
示例至C)
// Move file to a directory that's not in PATH
mv ~/Downloads/chromedriver ~/Documents/Python/ChromeDriver/
// Make file executable
chmod +x ~/Documents/Python/ChromeDriver/chromedriver
// Create a symlink to 'chromedriver' in one of the directories
// that are already in PATH (e.g. /usr/bin or /usr/local/bin)
sudo ln -s ~/Documents/Python/ChromeDriver/chromedriver /usr/bin/chromedriver
我希望我能说清楚。