2012-06-16 17 views
0

我試圖從開始一個python的過程phantomjs但由於某種原因它沒有找到我的腳本文件:Phantomjs在Windows中沒有找到腳本7

PHANTOM = 'C:\\Users\\ahald1\\phantomjs' 
    SCRIPT = 'C:\\Users\\ahald1\\hello.js' 
    params = [PHANTOM, SCRIPT] 
    exitcode = subprocess.call(params) 

其中hello.js包含:

console.log('Hello, world!'); 
    phantom.exit(); 

This returns Can't open 'C:\Users\ahald1\hello.js'

試圖從cmd執行此操作會返回相同的錯誤,但phantomjs --version確實會返回值。我在Windows 7上運行python 2.7.3。

對不起,對於新手問題,非常感謝!

回答

1

很可能,您已將文件hello.js保存在不同的文件名下,例如hello.js.txt。如果您將文件保存在記事本中或其他編輯器的文件類型不是所有文件,則可能發生這種情況。確保enable file extension display

或者,您可能已將hello.js文件保存在與C:\Users\ahald1\不同的目錄中。

+0

雅絕對搞砸了文件名。非常感謝您的幫助,如果我可以讓你高興,我會的! – user1460878