无法在mac中使用python启动selenium

时间:2014-12-31 10:03:27

标签: python eclipse macos selenium pydev

我在Mac OS中遇到了使用python进行selenium的问题。 Python 2.7 pydev 3.0

我的示例代码

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.formsite.com/")
driver.maximize_window()
driver.close()

使用PIP安装硒

pip install selenium
Downloading/unpacking selenium
  Downloading selenium-2.44.0.tar.gz (2.6MB): 2.6MB downloaded
  Running setup.py (path:/private/var/folders/qw/ctlmndfd5ts9w2p6v1qc382r0000gn/T/pip_build_bhanusaa/selenium/setup.py) egg_info for package selenium

Installing collected packages: selenium
  Running setup.py install for selenium

Successfully installed selenium

在Python Path库中分配/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages enter image description here

低于错误

Traceback (most recent call last):
  File "/Users/bhanusaa/Desktop/samp/src/scripts/new.py", line 3, in <module>
    driver = webdriver.Firefox()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
    self.binary, timeout),
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 65, in launch_browser
    self._start_from_profile_path(self.profile.path)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 88, in _start_from_profile_path
    env=self._firefox_env).communicate()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

1 个答案:

答案 0 :(得分:-1)

现在这个问题已经解决,以前我已经在我的Mac上安装了Firefox 34.0,现在降级到30.0,现在它运行正常。