【问题标题】:Phantomjs not finding script in Windows 7Phantomjs 在 Windows 7 中找不到脚本
【发布时间】:2012-06-16 18:48:35
【问题描述】:

我正在尝试从 python 启动一个 phantomjs 进程,但由于某种原因它没有找到我的脚本文件:

    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();

这会返回Can't open 'C:\Users\ahald1\hello.js'

尝试从 cmd 执行此操作会返回相同的错误,但 phantomjs --version 确实会返回一个值。我在 Windows 7 上运行 python 2.7.3。

很抱歉这个新手问题,提前非常感谢!

【问题讨论】:

    标签: python windows-7 phantomjs


    【解决方案1】:

    很可能,您已将文件 hello.js 保存在不同的文件名下,例如 hello.js.txt。如果您将文件保存在记事本或其他文件类型不是 所有文件 的编辑器中,则可能会发生这种情况。确保enable file extension display

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

    【讨论】:

    • 你肯定弄乱了文件名。非常感谢您的帮助,如果我可以投票给您,我会的!
    猜你喜欢
    • 2021-05-05
    • 1970-01-01
    • 2011-11-07
    • 2018-03-02
    • 1970-01-01
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    • 2013-06-08
    相关资源
    最近更新 更多