wxPython的安装

要在这个上面弄点东东了.于是今天装了一下。还是有一些问题的,所以记录一下吧。
具体的安装,可以参见http://www.wxpython.org/builddoc.php,记录的是最详细的
但是也许刚看的时候,可能没有耐心认真仔细的阅读,导致安装出错,中文解释一下:

1。安装wxWiget包:

     1.1安装 

$ sudo yum install gtk2-devel 
$ sudo yum install libSM-devel

     1.2解压后在其目录下建立bld文件夹,然后运行configure:

mkdir bld
cd bld
../configure --prefix=/usr/local/wx2.8 --with-gtk --with-gnomeprint --with-opengl --enable-debug --enable-geometry --enable-graphics_ctx --enable-sound --with-sdl --enable-mediactrl --enable-display --disable-debugreport --enable-unicode --with-libjpeg=builtin --with-libpng=builtin --with-libtiff=builtin --with-zlib=builtin

安装报错:

configure: error: OpenGL libraries not available 

$ sudo yum install mesa-libGL-devel 

$ sudo yum install mesa-libGLU-devel

2。编译安装:

制作一个脚本,命名为.make,放到bld目录下,内容如下:

make $* 
make -C contrib/src/gizmos $* 
make -C contrib/src/stc $*

然后运行:

chmod u+x .make
./.make
./.make install

3。安装wxPython:

解压,然后在它的wxPython目录里运行:

python setup.py build_ext --inplace --debug WX_CONFIG=$opt/wx2.8/bin/wx-config BUILD_GLCANVAS=0

BUILD_GLCANVAS=0,这个很关键哦,开始出现一大堆编译错误都是因为它。后来看见文档中,

If you get errors about being unable to find libGLU, wxGLCanvas being undeclared, or something similar then you can add BUILD_GLCANVAS=0 to the setup.py command line to disable the building of the glcanvas module.豁然开朗

WX_CONFIG=$opt/wx/2.8/bin/wx-config 中的路径为configure时设置的路径

4。设置环境变量:

export LD_LIBRARY_PATH=$opt/wx2.8/lib
export PYTHONPATH=$opt/wxPython-2.8.3.0/wxPython

当然,用export的方法,只能在当前终端有效啦,所以,我们还是最好修改.bash_profile文件,这样,无论在哪个终端,都好使啦。

测试一下,运行wxPython目录下的demo:

python demo.py
  OK,搞定啦!!!

你可能感兴趣的:(wxPython,PythonGUI)