Running phantomjs inside python virtualenv for selenium project

I'm on OSX

I need to use PhantomJS in Python # 3.5 scrapper working with selenium. I wrote a working program without first defining a virtual environment. It works fine, but now I started creating a virtual environment using virtualenv and copying my code inside the newly created environment. Everything works fine ... But PhantomJs and Firefox.

I pointed the path to phantomJS

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

I get:

selenium.common.exceptions.WebDriverException: Message: The /Users/Me/.npm-packages/bin/phantomjs service terminated unexpectedly. Status Code: 127

I decided to try installing the nodeenv environment inside my virtualenv.

I activated my virtualenv and did:

 pip install nodeenv 

Then:

 nodeenv -p 

returns error [SSL: CERTIFICATE_VERIFY_FAILED] ...

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

 nodeenv Path/To/MyVirtualEnv/MyNodeEnv 

Then I activated the NodeEnv environment

 Path/To/MyVirtualEnv/MyNodeEnv . bin/activate 

I installed PhantomJs:

 npm install phantomjs 

'What phantomjs still believe my globally installed phantomjs

In any case, I indicated a new path to phantomJS:

 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 left. Status Code: 127

I am stuck. Do you have any idea what I can do or something is wrong? Thanks.

+1
source share

All Articles