我在Mac OS X上使用全局PhantomJS进行多个Javascript和Python selenium项目。我第一次使用virtualenv建立了一个虚拟环境:
virtualenv Python3.5 Path/To/MyEnvironnement
然后:
Path/To/MyEnvironnement
. bin/activate
which phantomjs
...返回我的全球硒:/Users/Me/.npm-packages/bin/phantomjs
但每次我打电话:
driver = webdriver.PhantomJS(executable_path=r'/Users/Me/.npm-packages/bin/phantomjs')
我收到此错误:
Traceback (most recent call last):
File "/Path/To/MyEnvironnement/script/spider/crawl/Urls.py", line 194, in <module>
init_driver()
File "/Path/To/MyEnvironnement/script/spider/crawl/Urls.py", line 29, in init_driver
driver = webdriver.PhantomJS(executable_path=r'/Users/Me/.npm-packages/bin/phantomjs')
File "/Path/To/MyEnvironnement/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in __init__
self.service.start()
File "/Path/To/MyEnvironnement/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 86, in start
self.assert_process_still_running()
File "/Path/To/MyEnvironnement/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 99, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /Users/Me/.npm-packages/bin/phantomjs unexpectedly exited. Status code was: 127
自从我第一次遇到这个问题以来已经24小时了,我几乎阅读了所有可以引用它的帖子。
我试图在我的virtualenv中创建一个nodeenv但没有成功:running phantomjs inside python virtualenv for selenium project
答案 0 :(得分:3)
我猜它为时已晚,但为了将来参考,我已通过以下方式解决了这个问题:
AVCaptureSessionPresetInputPriority
答案在这里找到: