如何在ubuntu上将phantomjs 1.9.8更新为phantomjs 2.1.1?

如何在ubuntu上将phantomjs 1.9.8更新为phantomjs 2.1.1?,ubuntu,phantomjs,updates,reinstall,Ubuntu,Phantomjs,Updates,Reinstall,我无法在我的ubuntu 16.04上重新安装phantomjs 1.9.8到2.1.1版本 请帮忙。 1.9.8当我编写一个spin函数时,给我一个错误,在文档中,我可以通过重新存储来解决这个问题。我刚刚在ubuntu 16.04中安装了phantomjs 2.1.1,并执行了以下步骤,我通过谷歌搜索发现了这些步骤: sudo apt-get install nodejs sudo apt-get install nodejs-legacy sudo apt-get install npm s

我无法在我的ubuntu 16.04上重新安装phantomjs 1.9.8到2.1.1版本 请帮忙。
1.9.8当我编写一个spin函数时,给我一个错误,在文档中,我可以通过重新存储来解决这个问题。

我刚刚在ubuntu 16.04中安装了phantomjs 2.1.1,并执行了以下步骤,我通过谷歌搜索发现了这些步骤:

sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo apt-get install npm
sudo npm -g install phantomjs-prebuilt

如果我正在开发,我会这样做。这些软件包的版本为nodejs,而不是ubuntu:

使用
nvm

也许我们正在开发
0.10、0.12、4.X、iojs4.X、6.X等
现在我们可以选择phantomjs的任何版本:

jmunsch@ubuntu:~$ npm show phantomjs@* version
phantomjs@0.0.1 '0.0.1'
phantomjs@0.0.2 '0.0.2'
phantomjs@0.0.3 '0.0.3'
phantomjs@0.0.4 '0.0.4'
phantomjs@0.0.5 '0.0.5'
phantomjs@0.0.6 '0.0.6'
phantomjs@0.0.7 '0.0.7'
phantomjs@0.0.8 '0.0.8'
phantomjs@0.0.9 '0.0.9'
phantomjs@0.1.0 '0.1.0'
phantomjs@0.1.1 '0.1.1'
phantomjs@0.2.0 '0.2.0'
phantomjs@0.2.1 '0.2.1'
phantomjs@0.2.2 '0.2.2'
phantomjs@0.2.3 '0.2.3'
phantomjs@0.2.4 '0.2.4'
phantomjs@0.2.5 '0.2.5'
phantomjs@0.2.6 '0.2.6'
phantomjs@1.9.8 '1.9.8'
phantomjs@1.9.9 '1.9.9'
phantomjs@1.9.10 '1.9.10'
phantomjs@1.9.11 '1.9.11'
phantomjs@1.9.12 '1.9.12'
phantomjs@1.9.13 '1.9.13'
phantomjs@1.9.15 '1.9.15'
phantomjs@1.9.16 '1.9.16'
phantomjs@1.9.17 '1.9.17'
phantomjs@1.9.18 '1.9.18'
phantomjs@1.9.19 '1.9.19'
phantomjs@2.1.1 '2.1.1'
phantomjs@2.1.2 '2.1.2'
phantomjs@2.1.3 '2.1.3'
phantomjs@1.9.20 '1.9.20'
phantomjs@2.1.7 '2.1.7'
部署场景等的系统范围。 下面是如何使用柏油球

export PHANTOM_JS_VERSION=2.1.1
wget "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"
tar xvfj "./phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"
ln -sf "./phantomjs-$PHANTOM_JS_VERSION-linux-x86_64/bin/phantomjs" "/usr/bin"
在ubuntu 14.04上测试,可能会将文件夹移动到
/

16.04更新: 工作组可能工作,也可能不工作,请参见:

错误 phantomjs:加载共享库时出错:libfontconfig.so.1:无法打开共享对象文件:没有这样的文件或目录

尝试:


对于像我这样安装有问题的人

这比你想象的要简单…

  • 我卸载phantomjs:从ubuntu中删除phantomjs
    sudo apt get Remove phantomjs
    或删除
    /node\u modules/phantomjs
    的npm文件夹,它将位于
    /
    ,可能您需要删除
    ln
    中的phantomjs链接
    /usr/bin
    /usr/local/bin/
    它的名称是
    phantomjs
范例

//use this if you installed with apt-get
sudo apt-get remove phantomjs    *remove the phantomjs
rm /usr/bin/phantomjs            *use this if the link didn't remove.

//use this if you installed from npm: like this: npm install phantomjs
rm -R /node_modules/phantomjs    *note: it will be in other folder, search it.
cd /;
npm install phantomjs
//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
  • 从npm安装phantomjs:
    npm从
    /
    目录安装phantomjs
    ,npm将其安装在文件夹
    /node\u module/phantomjs
范例

//use this if you installed with apt-get
sudo apt-get remove phantomjs    *remove the phantomjs
rm /usr/bin/phantomjs            *use this if the link didn't remove.

//use this if you installed from npm: like this: npm install phantomjs
rm -R /node_modules/phantomjs    *note: it will be in other folder, search it.
cd /;
npm install phantomjs
//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
  • 测试箱文件
范例

//use this if you installed with apt-get
sudo apt-get remove phantomjs    *remove the phantomjs
rm /usr/bin/phantomjs            *use this if the link didn't remove.

//use this if you installed from npm: like this: npm install phantomjs
rm -R /node_modules/phantomjs    *note: it will be in other folder, search it.
cd /;
npm install phantomjs
//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
  • 将文件bin链接到
    /usr/bin

范例

//use this if you installed with apt-get
sudo apt-get remove phantomjs    *remove the phantomjs
rm /usr/bin/phantomjs            *use this if the link didn't remove.

//use this if you installed from npm: like this: npm install phantomjs
rm -R /node_modules/phantomjs    *note: it will be in other folder, search it.
cd /;
npm install phantomjs
//check version of phantomjs
/node_modules/phantomjs/bin/phantomjs -v
/node_modules/phantomjs/bin/phantomjs test.js
ln-sf/node_模块/phantomjs/bin/phantomjs/usr/bin/phantomjs

  • 检查它的版本,看看在我的情况下它是否正常
    phantomjs-v
    2.1.1

因此,jmunsch的答案对我来说很有效,但只是提供了一个清晰且简单的配方:

export PHANTOM_JS_VERSION=2.1.1

sudo apt-get install libfontconfig

wget "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"

tar xvfj "./phantomjs-$PHANTOM_JS_VERSION-linux-x86_64.tar.bz2"

ln -sf "$(pwd)/phantomjs-$PHANTOM_JS_VERSION-linux-x86_64/bin/phantomjs" "/usr/bin"

最后一行需要sudo,因为/usr/bin,但您可以将符号链接放在任何地方…

phantomjs 2.1.1目前与16.04()捆绑在一起,因此您应该能够将其作为系统包进行安装/升级

更新:此答案仅供参考,但由于以下问题,不建议现在使用系统软件包版本,例如:这与上游修复的文件上载问题有关,但修复的性质使其无法作为系统软件包使用


当前最好的选择是使用来自的预构建二进制文件:

由于已批准的步骤对我不起作用,我正在共享我找到的解决方案

# Install phantomJS
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

# Sanity check 
phantomjs --version
>>> 2.1.1

由于PhantomJS与node.js或npm(仅为方便而安装)无关,因此这将为一个二进制文件安装一个完整的生态系统,而该二进制文件与生态系统无关。npm需要NodeJ(和NodeJ遗留)才能成功安装phantomjs。我遵循的步骤是在python中与selenium一起使用的。完成后,始终可以卸载npm。这是让PhantomJS驱动程序与selenium一起工作的一种非常快速的方法。@3zzy您是对的,更新看起来像是一个依赖性问题,链接到相对路径可能是一个问题。另外,由于任何原因,wget不工作,因此我将沥青球转移到机器上。添加了github问题,出现了相同的403访问被拒绝错误。