Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pip安装selenium权限错误_Python_Selenium_Selenium Webdriver_Pip_Selenium3 - Fatal编程技术网

Python pip安装selenium权限错误

Python pip安装selenium权限错误,python,selenium,selenium-webdriver,pip,selenium3,Python,Selenium,Selenium Webdriver,Pip,Selenium3,我正在尝试使用默认python在mac上安装selenium 3,即/usr/bin/python 但是当我尝试使用 pip安装seleniumI收到错误 采硒 使用缓存 https://files.pythonhosted.org/packages/41/c6/78a9a0d0150dbf43095c6f422fdf6f948e18453c5ebbf92384175b372ca2/selenium-3.13.0-py2.py3-none-any.whl Installing collected

我正在尝试使用默认python在mac上安装selenium 3,即
/usr/bin/python
但是当我尝试使用

pip安装selenium
I收到错误 采硒 使用缓存

https://files.pythonhosted.org/packages/41/c6/78a9a0d0150dbf43095c6f422fdf6f948e18453c5ebbf92384175b372ca2/selenium-3.13.0-py2.py3-none-any.whl
Installing collected packages: selenium
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/selenium'
Consider using the `--user` option or check the permissions.
如果我使用
--user
作为
pip安装--user selenium
进行安装,它可以工作,但是当我使用代码运行测试时

driver = webdriver.Safari(executable_path="/Users/Desktop/selenium-server-standalone-3.13.0.jar")
我犯了一个错误

WebDriverException: Message: 'selenium-server-standalone-3.13.0.jar' executable may have wrong permissions. 

为什么我会出错,有没有一种方法可以在没有
--user
sudo
的情况下安装,因为即使使用这些选项,它也不起作用。

您使用
--user
解决了第一个问题-第二个问题是另一个问题

这一行
webdriver.Safari(executable_path=…)
指向了错误的路径-您应该将它指向Safari 10附带的
savaridriver
可执行文件所在的位置,而不是指向
.jar
文件

大概是这样的:

driver = webdriver.Safari(executable_path='/Applications/Safari.app/Contents/MacOS/safaridriver')

只需检查mac中的路径,找出您的
safaridriver
在哪里。

Sudo是Linux。还有,你为什么不想用它呢?