Cannot run PhantomJS with Flask on Ubuntu VPS
Figure out the problem, current phantomjs and init.py don't have enough permission to manipulate the service.py of ghostdriver. Here is the fix:
- Add a new user: "add username", then set "add username sudo"
- Login to the new user, make sure every command you run from now on starts with "sudo"
- In your flask application where init.py resides, create "ghostdriver.log" and "phantomjs" which is an executable file.
- Chmod both of them to 777 : init.py, ghostdriver.log and phantomjs
Set the custom config in init.py for phantomjs:
br = webdriver.PhantomJS(service_log_path='./ghostdriver.log', executable_path='./phantomjs')
That's it, now your selenium + flask + phantomjs is now working correctly.