I’m trying to start a phantomjs process from python but for some reason it’s not finding my script file:
PHANTOM = 'C:\\Users\\ahald1\\phantomjs'
SCRIPT = 'C:\\Users\\ahald1\\hello.js'
params = [PHANTOM, SCRIPT]
exitcode = subprocess.call(params)
Where hello.js contains:
console.log('Hello, world!');
phantom.exit();
This returns Can't open 'C:\Users\ahald1\hello.js'
Trying to do this from cmd returns the same error, but phantomjs --version does return a value. I’m running python 2.7.3 on Windows 7.
Sorry for the newbie question and thanks so much in advance!
Most likely, you have saved the file
hello.jsunder a different file name, for examplehello.js.txt. This may happen if you save a file in Notepad or another editor with a file type other than All Files. Make sure to enable file extension display.Alternatively, you may have saved the hello.js file in a different directory than
C:\Users\ahald1\.