ubuntu python3.6 安装 pyexecjs + nodejs/pyv8

1.通过pip安装pyexecjs

$ pip install PyExecJs

2.安装node.js

$ sudo apt-get install nodejs

3.python测试

import execjs
default=execjs.get(execjs.runtime_names.Node)

听说v8非常强大,于是就试着安装了下,不过这一装就是一下午,整理下思路。

我的环境:
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
$ uname -a
Linux WallGo 4.13.0-41-generic #46~16.04.1-Ubuntu SMP Thu May 3 10:06:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

1. 需要libboost,但是目前ubuntu使用apt安装的版本python2.7和python3.5

$ find /usr/ -name libboost*python*
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python.so
/usr/lib/x86_64-linux-gnu/libboost_mpi_python-py27.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0
/usr/lib/x86_64-linux-gnu/libboost_python.a
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so
/usr/lib/x86_64-linux-gnu/libboost_mpi_python.so
/usr/lib/x86_64-linux-gnu/libboost_mpi_python-py35.a
/usr/lib/x86_64-linux-gnu/libboost_mpi_python.a
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so.1.58.0
/usr/lib/x86_64-linux-gnu/libboost_mpi_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py35.a
/usr/lib/x86_64-linux-gnu/libboost_mpi_python-py27.so.1.58.0
/usr/lib/x86_64-linux-gnu/libboost_mpi_python-py35.so
/usr/lib/x86_64-linux-gnu/libboost_mpi_python-py35.so.1.58.0
/usr/lib/x86_64-linux-gnu/libboost_python-py27.a

于是需要自己编译libboost和安装

$ wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2
$ tar xf boost_1_67_0.tar.bz2
$ cd boost_1_67_0
$ ./bootstrap.sh
$ ./b2
$ ./b2 install

2. 安装pyv8

$ pip install PyV8

3. 测试PyV8

import PyV8
default=execjs.get(execjs.runtime_names.PyV8)

另外如果用源码安装pyv8,下面是参考

$ wget https://github.com/v8/v8/archive/master.zip
$ mv master.zip v8.zip && unzip v8.zip
$ git clone https://github.com/buffer/pyv8.git
$ export V8_HOME='~/workspace/source_got/v8'
$ python setup.py build
$ python setup.py install

其他的引擎感觉上用得不是这么多,有兴趣或者时间可以试试

阅读更多

没有更多推荐了,返回首页