Search code examples
pythonseleniumselenium-webdriverpipselenium3

pip install selenium permission error


I am trying to install selenium 3 on mac using default python i.e. /usr/bin/python But when I try to install it https://pypi.org/project/selenium/ using

pip install selenium I get error Collecting selenium Using cached

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.

If i install using --user as pip install --user selenium it works but when I run test with code

driver = webdriver.Safari(executable_path="/Users/Desktop/selenium-server-standalone-3.13.0.jar")

I get error

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

Why I'm getting error and is there a way to install without --user and sudo because even with these options it doesn't work.


Solution

  • You solved the first problem by using --user - the second problem is a different issue.

    this line webdriver.Safari(executable_path=...) is pointing to the wrong path - you should point it to wherever the savaridriver executable that comes with safari 10 and not to a .jar file.

    Something like this:

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

    Just check the path in your mac and find out where your safaridriver is.