简体   繁体   English

如何在Ubuntu 14.04中安装pyv8?

[英]How can I install pyv8 in Ubuntu 14.04?

I installed the libv8 and libboost-all-dev Ubuntu packages, then ran 我安装了libv8libboost-all-dev Ubuntu软件包,然后运行

sudo pip install pyv8

And got: 并得到:

building '_PyV8' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DBOOST_PYTHON_STATIC_LIB -Ilib/python/inc -Ilib/boost/inc -Ilib/v8/inc -I/usr/include/python2.7 -c src/Exception.cpp -o build/temp.linux-x86_64-2.7/src/Exception.o

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]

src/Exception.cpp: In static member function ‘static void ExceptionTranslator::Construct(PyObject*, boost::python::converter::rvalue_from_python_stage1_data*)’:

src/Exception.cpp:207:25: warning: unused variable ‘cpp_err’ [-Wunused-variable]

   CJavascriptException* cpp_err =

                         ^

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DBOOST_PYTHON_STATIC_LIB -Ilib/python/inc -Ilib/boost/inc -Ilib/v8/inc -I/usr/include/python2.7 -c src/Context.cpp -o build/temp.linux-x86_64-2.7/src/Context.o

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]

In file included from src/Context.h:7:0,

                 from src/Context.cpp:1:

src/Wrapper.h: In member function ‘const boost::python::api::object& CJavascriptArray::ArrayIterator::dereference() const’:

src/Wrapper.h:115:66: warning: returning reference to temporary [-Wreturn-local-addr]

     reference dereference() const { return m_array->GetItem(m_idx); }

                                                                  ^

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DBOOST_PYTHON_STATIC_LIB -Ilib/python/inc -Ilib/boost/inc -Ilib/v8/inc -I/usr/include/python2.7 -c src/Engine.cpp -o build/temp.linux-x86_64-2.7/src/Engine.o

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]

In file included from src/Context.h:7:0,

                 from src/Engine.h:7,

                 from src/Engine.cpp:1:

src/Wrapper.h: In member function ‘const boost::python::api::object& CJavascriptArray::ArrayIterator::dereference() const’:

src/Wrapper.h:115:66: warning: returning reference to temporary [-Wreturn-local-addr]

     reference dereference() const { return m_array->GetItem(m_idx); }

                                                                  ^

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DBOOST_PYTHON_STATIC_LIB -Ilib/python/inc -Ilib/boost/inc -Ilib/v8/inc -I/usr/include/python2.7 -c src/Wrapper.cpp -o build/temp.linux-x86_64-2.7/src/Wrapper.o

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]

In file included from src/Wrapper.cpp:1:0:

src/Wrapper.h: In member function ‘const boost::python::api::object& CJavascriptArray::ArrayIterator::dereference() const’:

src/Wrapper.h:115:66: warning: returning reference to temporary [-Wreturn-local-addr]

     reference dereference() const { return m_array->GetItem(m_idx); }

                                                                  ^

src/Wrapper.cpp: In static member function ‘static v8::Handle<v8::Boolean> CPythonObject::IndexedDeleter(uint32_t, const v8::AccessorInfo&)’:

src/Wrapper.cpp:256:25: warning: variable ‘value’ set but not used [-Wunused-but-set-variable]

   v8::Handle<v8::Value> value = IndexedGetter(index, info);

                         ^

src/Wrapper.cpp: In static member function ‘static void CPythonObject::SetupObjectTemplate(v8::Handle<v8::ObjectTemplate>)’:

src/Wrapper.cpp:311:84: error: invalid conversion from ‘v8::Handle<v8::Boolean> (*)(v8::Local<v8::String>, const v8::AccessorInfo&)’ to ‘v8::NamedPropertyQuery {aka v8::Handle<v8::Integer> (*)(v8::Local<v8::String>, const v8::AccessorInfo&)}’ [-fpermissive]

   clazz->SetNamedPropertyHandler(NamedGetter, NamedSetter, NamedQuery, NamedDeleter);

                                                                                    ^

In file included from src/Exception.h:6:0,

                 from src/Wrapper.h:8,

                 from src/Wrapper.cpp:1:

/usr/include/v8.h:2414:8: error:   initializing argument 3 of ‘void v8::ObjectTemplate::SetNamedPropertyHandler(v8::NamedPropertyGetter, v8::NamedPropertySetter, v8::NamedPropertyQuery, v8::NamedPropertyDeleter, v8::NamedPropertyEnumerator, v8::Handle<v8::Value>)’ [-fpermissive]

   void SetNamedPropertyHandler(NamedPropertyGetter getter,

        ^

src/Wrapper.cpp:312:94: error: invalid conversion from ‘v8::Handle<v8::Boolean> (*)(uint32_t, const v8::AccessorInfo&) {aka v8::Handle<v8::Boolean> (*)(unsigned int, const v8::AccessorInfo&)}’ to ‘v8::IndexedPropertyQuery {aka v8::Handle<v8::Integer> (*)(unsigned int, const v8::AccessorInfo&)}’ [-fpermissive]

   clazz->SetIndexedPropertyHandler(IndexedGetter, IndexedSetter, IndexedQuery, IndexedDeleter);

                                                                                              ^

In file included from src/Exception.h:6:0,

                 from src/Wrapper.h:8,

                 from src/Wrapper.cpp:1:

/usr/include/v8.h:2437:8: error:   initializing argument 3 of ‘void v8::ObjectTemplate::SetIndexedPropertyHandler(v8::IndexedPropertyGetter, v8::IndexedPropertySetter, v8::IndexedPropertyQuery, v8::IndexedPropertyDeleter, v8::IndexedPropertyEnumerator, v8::Handle<v8::Value>)’ [-fpermissive]

   void SetIndexedPropertyHandler(IndexedPropertyGetter getter,

        ^

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/pyv8/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-JQHgTo-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/pyv8
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 235, in main
    return command.main(cmd_args)
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)

What's going wrong? 怎么了 How can I fix it? 我该如何解决?

To solve this, I had to remove some of the Ubuntu packages I tried: 为了解决这个问题,我不得不删除一些我尝试过的Ubuntu软件包:

$ sudo apt-get purge libv8-3.14.5 libv8-dev

Then, checkout PyV8 from subversion 然后,从Subversion检出PyV8

$ svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8-read-only

The setup.py script took care of fetching and building the compatable version of V8: setup.py脚本负责获取和构建V8的兼容版本:

$ cd pyv8-read-only
$ python setup.py build
$ sudo python setup.py install

To build from source using pip, you can run: 要使用pip从源代码进行构建,可以运行:

pip install svn+http://pyv8.googlecode.com/svn/trunk/

Or using flier (the author, it seems)'s migrated github repository : 或使用flier (看来是作者)的已迁移github存储库

pip install git+https://github.com/flier/pyv8.git

I was running into several different errors while trying to install PyV8. 尝试安装PyV8时遇到了几个不同的错误。 I didn't try to dig deeper into why exactly the different errors were happening. 我没有试图更深入地研究为什么会发生不同的错误。 I am on Ubuntu 16.04 64bit version. 我使用的是Ubuntu 16.04 64位版本。

I followed the following instructions 我遵循以下指示

sudo apt-get install libboost-all-dev
sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev
sudo easy_install greenlet
sudo easy_install gevent
git clone https://github.com/buffer/pyv8.git
cd pyv8
sudo python setup.py build
sudo python setup.py install

and was able to install and use PyV8 并能够安装和使用PyV8

This instruction was found here - https://github.com/buffer/thug/issues/170#issuecomment-225762492 该指令位于此处-https://github.com/buffer/thug/issues/170#issuecomment-225762492

Hope this helps. 希望这可以帮助。

我使用本指南安装“ PyV8”: 将PyV8 Engine导入Python 2.7,这对我来说很简单 :)

To install PyV8 on a Debian based distro: 要在基于Debian的发行版上安装PyV8:

cd /usr/share 光盘/ usr / share

sudo git clone https://github.com/emmetio/pyv8-binaries.git sudo git clone https://github.com/emmetio/pyv8-binaries.git

cd pyv8-binaries/ cd pyv8-binaries /

sudo unzip pyv8-linux64.zip sudo解压缩pyv8-linux64.zip

sudo cp -a PyV8.py _PyV8.so /usr/bin 须藤cp -a PyV​​8.py _PyV8.so / usr / bin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM