使用Anaconda3中的pip安装wxPython-Phoenix

时间:2015-08-09 14:53:46

标签: python wxpython install pip python-3.4

我在尝试创建Python 3.4 virtual environment用于试验wxPython Phoenix后,发现wxPython仅适用于Python2.7。 为此,我使用Anaconda3运行以下命令:

conda create --name wxpython-tutorial python=3
source activate wxpython-tutorial

然后我在wxPython website上找到了以下pip安装命令:

pip install --upgrade --trusted-host wxpython.org --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix > pip_install_log.log

这为我的CPU提供了很多工作,但不幸的是,它没有正确安装并且给我一个巨大的终端输出。我将粘贴该输出的红线并链接完整的日志文件:

Failed building wheel for wxPython-Phoenix
Command "/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5_va3b5w/wxPython-Phoenix/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-uzo3pvq4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-5_va3b5w/wxPython-Phoenix

我找不到任何关于这样一般失败消息(1.关于轮子的线路)或如此复杂的消息(2.以命令开头的行),所以我不知道什么是错的。此外,我没有看到任何更好的信息来源,如何在我的虚拟环境中安装它比官方wxPython网站。

Here是完整日志文件的链接。

我无法使用pastebin,文件大小为1.39Mb且超出了pastebin的限制:/

有什么问题,如何在虚拟环境中安装wxPython for Python 3.4?

编辑#1:已安装wxPython网站上列出的所有要求。我在运行pip命令之前检查了它。

编辑#2 :按照Robin Dunn的建议(安装libwebkit-dev)后,我能够正常运行pip安装。但是,现在我仍然无法使用它,因为当我尝试导入它时,会弹出另一个错误:

(wxpython-phoenix-tutorial)xiaolong@xiaolong-VPCF13J0E:~$ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Jun  4 2015, 15:29:08) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/__init__.py", line 17, in <module>
from wx.core import *
File "/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/core.py", line 6, in <module>
from ._core import *
ImportError: libwx_gtk2u_core-3.0.so.0: cannot open shared object file: No such file or directory
>>>

听起来像一个图书馆,应该在那里,但不是。它应该编译而不是吗?

修改#3

我运行了ldd命令RobinDunn建议,结果发现有3个文件缺失:

xiaolong@xiaolong-VPCF13J0E:~$ ldd /home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/_core*.so
linux-vdso.so.1 =>  (0x00007ffe867ed000)
libwx_gtk2u_core-3.0.so.0 => not found
libwx_baseu_net-3.0.so.0 => not found
libwx_baseu-3.0.so.0 => not found
libpython3.4m.so.1.0 => /home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/libpython3.4m.so.1.0 (0x00007fa08164c000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa081348000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa081042000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa080e2c000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa080c0e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa080849000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa080645000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fa080442000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa0827ec000)

看来,编译过程没有把它们放在那里。搜索它们显示,它们已被创建:

find /home/xiaolong/development/ -name "*libwx_gtk2u_core-3.0*"
/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/libwx_gtk2u_core-3.0.so
/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/libwx_gtk2u_core-3.0.so.0
/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/libwx_gtk2u_core-3.0.so.0.3.0

find /home/xiaolong/development/ -name "*libwx_baseu_net-3.0.so.0*"
/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/libwx_baseu_net-3.0.so.0.3.0
/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/libwx_baseu_net-3.0.so.0

find /home/xiaolong/development/ -name "*libwx_baseu-3.0.so.0*"
/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/libwx_baseu-3.0.so.0
/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/libwx_baseu-3.0.so.0.3.0

接下来我会尝试导出他们的位置。

修改#4 虽然我按照建议添加了库的位置:

export LD_LIBRARY_PATH=/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx

(我也试过了图书馆的完整路径) 我将该行添加到我的~/.profile文件和我的~/.bashrc文件中。 重新启动终端后,当我尝试在我的虚拟envs python中执行import wx时,我仍然得到相同的错误:

(wxpython-phoenix-tutorial)xiaolong@xiaolong-VPCF13J0E:~/development/anaconda3/envs/wxpython-phoenix-tutorial$ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Jun  4 2015, 15:29:08) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/__init__.py", line 17, in <module>
    from wx.core import *
  File "/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/core.py", line 6, in <module>
    from ._core import *
ImportError: libwx_gtk2u_core-3.0.so.0: cannot open shared object file: No such file or directory
>>> 

1 个答案:

答案 0 :(得分:1)

第一个编译错误是:

  ../../../sip/cpp/sip_html2cmodule.cpp:386:1: error: ‘wxWebView’ does not name a type

回溯到wxWidgets配置和构建,你可以看到:

  checking for WEBKIT... configure: WARNING: webkitgtk not found.
  configure: WARNING: WebKit not available, disabling wxWebView

所以基本上它告诉你需要为webkitgtk安装开发包。

编辑#2:

默认情况下,Phoenix的build.py会将它构建的wxWidgets共享库复制到wx包文件夹,并将扩展模块中的rpath设置为使用相对路径而不是库存固定来查找这些库像往常一样的路径这样做是为了使wxPython-Phoenix包可以重定位,以允许不同版本的不同版本等。

要检查这是否正确,请查看/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx并查看是否有一堆libwx_*个文件。这些是wxWidgets共享库。你也可以运行它来查看扩展是否能够找到这些库(可能不是因为你得到错误,但它可能会提供一些线索):

ldd /home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx/_core*.so

如果所有其他方法都失败了,那么你可以设置一个环境变量来使动态链接器能够以老式的方式找到这些库:

export LD_LIBRARY_PATH=/home/xiaolong/development/anaconda3/envs/wxpython-phoenix-tutorial/lib/python3.4/site-packages/wx