gpt4 book ai didi

linux - 无法在 Linux 上执行 PhantomJS

转载 作者:太空狗 更新时间:2023-10-29 12:30:57 24 4
gpt4 key购买 nike

一直在尝试在 Ubuntu 12.04 VM 上安装最新版本 (1.9.8) 的 phantomjs 但没有成功。这是我到目前为止所做的:

  1. 为了摆脱旧版本,执行

    sudo apt-get remove phantomjs
  2. 为了摆脱旧的符号链接(symbolic link),执行

    rm -r /.../phantomjs
  3. 将 phantomjs-1.9.8-linux-x86_64.tar.bz2.2 下载到/usr/local/share 目录并解压:

    sudo wget . . ..tar.bz2
    sudo tar xjf phantomjs-1.9.8-linux-x86_64.tar.bz2
  4. 创建到/usr/local/share/、/usr/local/bin/和/usr/bin 的新符号链接(symbolic link)

    sudo ln -s /usr/local/share/phantomjs-1.9.8-linux-x86_64/bin/phantomjs  /usr/. . ./phantomjs
  5. 检查版本:

    phantomjs --version 

这是返回的消息:

-bash: /usr/local/bin/phantomjs: cannot execute binary file

有人可以解释为什么会发生这种情况以及如何解决它吗?

最佳答案

建议使用 npm 安装:

sudo apt-get install nodejs npm 

有问题:

. . . 
nodejs is already the newest version.
Some packages could not be installed.
This may mean that you have requested an impossible situation or
if you are using the unstable distribution that some required packages have not yet been created
or been moved out of Incoming. The following information may help resolve the situation:
The following packages have unmet dependencies:
nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.

得知简单的 apt-get install nodejs 也安装了 npm,所以尝试了一下,然后是

sudo npm -g install phantomjs 

最后:

... 
Done. Phantomjs binary available at /usr/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs phantomjs@1.9.12
/usr/lib/node_modules/phantomjs
├── which@1.0.8
├── progress@1.1.8
├── rimraf@2.2.8
├── ncp@1.0.1 ├── kew@0.4.0
├── adm-zip@0.4.4
├── request-progress@0.3.1 (throttleit@0.0.2)
├── mkdirp@0.5.0 (minimist@0.0.8)
├── npmconf@2.0.9 (uid-number@0.0.5, inherits@2.0.1, osenv@0.1.0, ini@1.3.2, once@1.3.1,
config-chain@1.1.8, semver@4.1.0, nopt@3.0.1)
└── request@2.42.0 (caseless@0.6.0, json-stringify-safe@5.0.0, aws-sign2@0.5.0,
forever-agent@0.5.2, stringstream@0.0.4, oauth-sign@0.4.0, tunnel-agent@0.4.0, qs@1.2.2,
node-uuid@1.4.2, mime-types@1.0.2, http-signature@0.10.0, form-data@0.1.4, bl@0.9.3, hawk@1.1.1,
tough-cookie@0.12.1)

检查版本:

sudo phantomjs --version 
1.9.8

作为它已安装和工作的最终证明,重新运行之前失败的 cucumber 测试(无法通过,因为缺少 phantomjs),所有依赖于 phantomjs 的 cucumber 测试现在都通过了

关于linux - 无法在 Linux 上执行 PhantomJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27429267/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com