MAC安装chromedriver碰到的问题
MAC安装chromedriver碰到的问题:mv: rename chromedriver to /usr/bin/chromedriver: Operation not permitted
- 我想把从官网下载的文件chromedriver从下载文件夹转移到/usr/bin目录下
终端输入:
mv: rename chromedriver to /usr/bin/
报错 chromedriver: Operation not permitted
可以看到没有移动成功,报错了,Operation not permitted
搜索之后发现,是El Capitan 加入了Rootless机制,不再能够随心所欲的读写很多路径下了。设置 root 权限也不行。
Rootless机制将成为对抗恶意程序的最后防线
于是尝试关闭 Rootless。
重启按住 Command+R,进入恢复模式,第一步选择语言,然后点击显示器最上面实用工具菜单下的终端,打开Terminal。
输入
csrutil disable #关闭
具体效果如图所示
然后重启电脑,重复刚才的移动文件操作
[email protected] ~ cd pythonproject
[email protected] ~/pythonproject ls
ArticleSpider
[email protected] ~/pythonproject cd ArticleSpider
[email protected] ~/pythonproject/ArticleSpider ls
ArticleSpider articleexport.json scrapy.cfg
article.json main.py tools
[email protected] ~/pythonproject/ArticleSpider cd tools
[email protected] ~/pythonproject/ArticleSpider/tools ls
chromedriver selenium_spider.py
[email protected] ~/pythonproject/ArticleSpider/tools sudo mv chromedriver /usr/bin
Password:
[email protected] ~/pythonproject/ArticleSpider/tools cd /usr/bin
[email protected] /usr/bin ls
然后我们发现已经移动进去了,如图所示
然后通过python编写代码,就可以控制谷歌浏览器了。
效果如下