最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac中安装selenium出错:OSError Errno 13 Permission denied /usr/local/selenium

Mac crifan 2730浏览 0评论

折腾:

【记录】尝试用Python操作PhantomJS+Selenium去模拟购物操作

期间,在全局代理后,依然出错:

➜  自动下单 pip install -U selenium
Collecting selenium
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=’pypi.python.org‘, port=443): Read timed out. (read timeout=15)”,)’: /packages/d0/b1/1c9d9cc3fd6c1cd802d897d78a9ea5ad01b07c6c0f422b235717b74270ae/selenium-3.7.0-py2.py3-none-any.whl
  Downloading selenium-3.7.0-py2.py3-none-any.whl (935kB)
    100% |████████████████████████████████| 942kB 402kB/s
Installing collected packages: selenium
Exception:
Traceback (most recent call last):
  File “/usr/local/lib/python2.7/site-packages/pip/basecommand.py”, line 215, in main
    status = self.run(options, args)
  File “/usr/local/lib/python2.7/site-packages/pip/commands/install.py”, line 342, in run
    prefix=options.prefix_path,
  File “/usr/local/lib/python2.7/site-packages/pip/req/req_set.py”, line 784, in install
    **kwargs
  File “/usr/local/lib/python2.7/site-packages/pip/req/req_install.py”, line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File “/usr/local/lib/python2.7/site-packages/pip/req/req_install.py”, line 1064, in move_wheel_files
    isolated=self.isolated,
  File “/usr/local/lib/python2.7/site-packages/pip/wheel.py”, line 377, in move_wheel_files
    clobber(source, dest, False, fixer=fixer, filter=filter)
  File “/usr/local/lib/python2.7/site-packages/pip/wheel.py”, line 316, in clobber
    ensure_dir(destdir)
  File “/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py”, line 83, in ensure_dir
    os.makedirs(path)
  File “/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py”, line 150, in makedirs
    makedirs(head, mode)
  File “/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py”, line 150, in makedirs
    makedirs(head, mode)
  File “/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py”, line 150, in makedirs
    makedirs(head, mode)
  File “/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py”, line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: ‘/usr/local/selenium’

mac python OSError Errno 13 Permission denied /usr/local/selenium

Permission denied: ‘/Library/Python/2.7/site-packages/pync/vendor’ · Issue #1 · sindresorhus/weechat-notification-center

IOError: [Errno 13] Permission denied: ‘/usr/local/bin/pip’ · Issue #4186 · pypa/pip

OSError:[Errno 13]Permission denied解决方法 – CSDN博客

14.04 – OSError: [Errno 13] Permission denied: ‘/usr/local/lib/python2.7/dist-packages/pelican-3.6.3.dist-info’ – Ask Ubuntu

pip install –upgrade without permissions deletes old pip before failing · Issue #3761 · pypa/pip

看了看权限:

➜  自动下单 ll /usr/local
total 24
-rw-r–r–@   1 crifan  admin   3.1K  5 14  2016 CODEOFCONDUCT.md
drwxr-xr-x@  18 crifan  admin   612B  5  6  2017 Cellar
drwxr-xr-x@   4 crifan  admin   136B  5  6  2017 Frameworks
drwxrwxr-x@  17 crifan  admin   578B  9 26 17:56 Homebrew
-rw-r–r–@   1 crifan  admin   1.2K  1 13  2016 LICENSE.txt
drwxr-xr-x@  11 crifan  admin   374B  5 14  2016 Library
-rw-r–r–@   1 crifan  admin   3.8K  5 14  2016 README.md
drwxr-xr-x@   3 root    wheel   102B  8 14 21:39 Watchdata
drwxrwxr-x  128 crifan  admin   4.3K 11  6 14:18 bin
drwxr-xr-x@   6 crifan  admin   204B  3  3  2017 etc
drwxr-xr-x   12 crifan  admin   408B  5  6  2017 include
drwxr-xr-x   28 crifan  admin   952B  5  6  2017 lib
drwxr-xr-x@   4 root    wheel   136B  8 14 21:37 libexec
drwxr-xr-x@   3 root    wheel   102B  6  9 14:26 n
drwxr-xr-x@  21 crifan  admin   714B  9 26 18:09 opt
drwxr-xr-x@   3 crifan  wheel   102B  2 15  2017 remotedesktop
drwxrwxr-x@   2 crifan  admin    68B  2 17  2017 sbin
drwxrwxr-x   10 crifan  admin   340B  5  6  2017 share
drwxrwxr-x@   4 crifan  admin   136B  3  4  2017 var

好像没问题啊。

去看看当前自己的用户:

➜  自动下单 echo $USER

crifan

但是去创建,果然有问题:

➜  自动下单 mkdir /usr/local/selenium

mkdir: /usr/local/selenium: Permission denied

所以先去:

➜  自动下单 sudo chown -R crifan /usr/local

Password:

然后再去看看:

➜  自动下单 ll /usr
total 0
drwxr-xr-x  1067 root    wheel    35K 11  9 09:08 bin
。。。
drwxr-xr-x@   26 crifan  wheel   884B  8 23 08:44 local

然后再去试试:

mkdir /usr/local/selenium

就可以了。

所以估计可以去安装了。

然后就再去安装:

➜  自动下单 pip install -U selenium
Requirement already up-to-date: selenium in /usr/local/lib/python2.7/site-packages
➜  自动下单 pip install selenium
Requirement already satisfied: selenium in /usr/local/lib/python2.7/site-packages
➜  自动下单 pip uninstall selenium
Uninstalling selenium-3.7.0:
  /usr/local/lib/python2.7/site-packages/selenium-3.7.0.dist-info/DESCRIPTION.rst
  /usr/local/lib/python2.7/site-packages/selenium-3.7.0.dist-info/METADATA
  /usr/local/lib/python2.7/site-packages/selenium-3.7.0.dist-info/RECORD
  /usr/local/lib/python2.7/site-packages/selenium-3.7.0.dist-info/WHEEL
  /usr/local/lib/python2.7/site-packages/selenium-3.7.0.dist-info/metadata.json
  /usr/local/lib/python2.7/site-packages/selenium-3.7.0.dist-info/top_level.txt
  /usr/local/lib/python2.7/site-packages/selenium/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/common/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/common/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/common/exceptions.py
  /usr/local/lib/python2.7/site-packages/selenium/common/exceptions.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/android/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/android/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/android/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/android/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/blackberry/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/blackberry/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/blackberry/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/blackberry/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/options.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/options.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/remote_connection.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/remote_connection.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/service.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/service.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/action_builder.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/action_builder.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/input_device.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/input_device.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/interaction.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/interaction.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/key_actions.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/key_actions.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/key_input.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/key_input.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/mouse_button.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/mouse_button.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/pointer_actions.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/pointer_actions.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/pointer_input.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/actions/pointer_input.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/alert.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/alert.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/by.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/by.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/desired_capabilities.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/desired_capabilities.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/html5/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/html5/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/html5/application_cache.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/html5/application_cache.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/keys.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/keys.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/proxy.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/proxy.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/touch_actions.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/touch_actions.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/utils.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/common/utils.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/options.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/options.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/service.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/service.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/edge/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/amd64/x_ignore_nofocus.so
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_profile.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_profile.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/options.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/options.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/remote_connection.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/remote_connection.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/service.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/service.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.xpi
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver_prefs.json
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webelement.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webelement.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/x86/x_ignore_nofocus.so
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/options.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/options.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/service.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/service.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/ie/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/opera/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/opera/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/opera/options.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/opera/options.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/opera/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/opera/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/service.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/service.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/command.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/command.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/file_detector.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/file_detector.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/getAttribute.js
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/isDisplayed.js
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/mobile.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/mobile.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/switch_to.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/switch_to.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/utils.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/utils.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/safari/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/safari/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/safari/service.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/safari/service.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/safari/webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/safari/webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/__init__.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/__init__.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/abstract_event_listener.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/abstract_event_listener.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/color.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/color.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/event_firing_webdriver.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/event_firing_webdriver.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/events.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/events.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/expected_conditions.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/expected_conditions.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/select.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/select.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/ui.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/ui.pyc
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/wait.py
  /usr/local/lib/python2.7/site-packages/selenium/webdriver/support/wait.pyc
Proceed (y/n)? y
  Successfully uninstalled selenium-3.7.0
➜  自动下单
➜  自动下单 pip install -U selenium
Collecting selenium
  Using cached selenium-3.7.0-py2.py3-none-any.whl
Installing collected packages: selenium
Successfully installed selenium-3.7.0

【总结】

此处Mac中默认的/usr/local的用户是root

当前用户是crifan

虽然同属于admin组,但是却没有权限在/usr/local中创建文件夹,导致安装selenium失败。

解决办法:

给/usr/local加上权限,或者把拥有者ower换成自己:

sudo chown -R crifan /usr/local

(或:sudo chown -R $USER /usr/local)

然后即可正常安装python库。

转载请注明:在路上 » 【已解决】Mac中安装selenium出错:OSError Errno 13 Permission denied /usr/local/selenium

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.196 seconds, using 22.12MB memory