running phantomjs inside python virtualenv for selenium project

若如初见. 提交于 2020-01-04 12:40:47

问题


I am on OSX

I need to use PhantomJS in a Python#3.5 scrapper running with selenium. I wrote a working program without setting a virtual environnement first. It works fine, but now I started building a virtual environnement with virtualenv and copied my code inside the newly created environnement. Everything is working fine... But PhantomJs and Firefox.

I specified the path to phantomJS

driver = webdriver.PhantomJS(executable_path=r'/Users/Me/.npm-packages/bin/phantomjs')

I get :

selenium.common.exceptions.WebDriverException: Message: Service /Users/Me/.npm-packages/bin/phantomjs unexpectedly exited. Status code was: 127

I decided to try and install a nodeenv environnement inside my virtualenv.

I activated my virtualenv and did :

pip install nodeenv

Then:

nodeenv -p

returns an [SSL: CERTIFICATE_VERIFY_FAILED] error...

so I launched a new terminal window, and used a global nodeenv to install my node environnement :

nodeenv Path/To/MyVirtualEnv/MyNodeEnv

I then activated my NodeEnv environnement

Path/To/MyVirtualEnv/MyNodeEnv
. bin/activate

I installed PhantomJs:

npm install phantomjs

'Which phantomjs' still returns my globally installed phantomjs

I specified a new path to phantomJS anyway :

driver = webdriver.PhantomJS(executable_path=r'/Path/To/MyVirtualEnv/MyNodeEnv/node_modules/phantomjs/bin/phantomjs')

... and I get the same error :

selenium.common.exceptions.WebDriverException: Message: Service /Users/PierreEligny/Documents/PRO/peecks_bot/nodeenv/node_modules/phantomjs/bin/phantomjs unexpectedly exited. Status code was: 127

I am stuck. Do you have any ideas what I could do or did wrong ? Thanks.

来源:https://stackoverflow.com/questions/40087878/running-phantomjs-inside-python-virtualenv-for-selenium-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!