ubuntu安装wxpython库

概述

为了做一个小程序,要用到wxpython这个库,所以就需要安装下,因为我是使用pyenv去管理python的,所以安装这个库就使用pip安装了,系统是ubuntu16.04,python版本是2.7.14

操作

首先使用下面命令安装wxpython
pip install -U wxPython
报错

1
2
3
4
5
6
7
configure: error:
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that gtk+-2.0.pc is
installed. For GTK+ 1.2 please check that gtk-config is in the path,
and that the version is 1.2.3 or above. Also check that the
libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
--libs' are in the LD_LIBRARY_PATH or equivalent.

安装下面这个库才可以解决
sudo apt-get install libgtk-3-dev
之后重新执行安装命令,又报错
configure: error: OpenGL libraries not available
安装下面这个包再重新执行安装命令
sudo apt install freeglut3-dev
接着又报错

1
2
3
4
5
checking for GST... configure: WARNING: GStreamer 1.0 not available, falling back to 0.10     
checking for GST... configure: WARNING: GStreamer 0.10 not available, falling back to 0.8
configure: error: GStreamer not available
Error running configure
ERROR: failed building wxWidgets

安装下面这个包再重新执行安装命令
sudo apt install libgstreamer-plugins-base1.0-dev
接着安装的时候又报错,这个报错无解

1
2
3
4
5
6
7
8
9
Checking for header Python.h                                                                                                        : :-(
Asking python-config for pyembed --cflags flags : yes
Asking python-config for pyembed --libs flags : yes
Asking python-config for pyembed --ldflags flags : yes
Getting pyembed flags from python-config : yes
Asking python-config for pyext --cflags flags : yes
Asking python-config for pyext --libs flags : yes
Asking python-config for pyext --ldflags flags : yes
Getting pyext flags from python-config : Could not build python extensions

如果有知道的告诉我下,其实上面的这些依赖关系官方都说明了

1
2
3
4
5
6
7
You will need the following packages (please consult your distributions package list for the appropriate names) and their dependencies:

python-dev (for your version of python)
gtk (preferably version 3, but depends on your needs)
gstreamer
glut
webkitgtk (matching your gtk version)

地址: https://wxpython.org/blog/2017-08-17-builds-for-linux-with-pip/index.html

而且在ubuntu安装wxpython的话有ubuntu的版本的,直接运行下面的命令安装就好了

1
2
3
pip install -U \
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 \
wxPython

欢迎关注Bboysoul的博客www.bboy.app
Have Fun

欢迎关注我的其它发布渠道