2016-10-18 90 views
6

我在我的Mac OS X上使用全局PhantomJS來執行多個Javascript和Python硒項目。這是第一次,我建立了一個虛擬環境在使用的virtualenv:PhantomJS意外退出Selenium:WebDriverException狀態碼爲127

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

我試圖運行使用我的全球的Python 3.5的代碼,一切工作正常。 – user6403833

回答

相關問題