1、前言

本文主要讲述在linux环境下进行编译wxpython,在windows下面安装wxpython很简单,只要下载,然后直接执行exe文件,下一步下一步即可安装,在linux下面,则具有很多步骤。

wxpython下载地址为:

http://wxpython.org/download.php

具体的源码下载路径在最下面的位置,名称为wxPython-src,点击即可下载。下载的文件名称为wxPython-src-3.0.2.0.tar.bz2.

2、解压

进行解压:

[root@FTP ~]# tar -jxvf wxPython-src-3.0.2.0.tar.bz2

3、安装依赖包

gtk2,gtk2-devel,python-devel,tk,tk-devel,gstreamer,gstreamer-devel,mesa-libGL-devel,
mesa-libGLU-devel,mesa-libGLU,mesa-libGL,libSM,libSM-devel,gstreamer-plugins-base-devel

最好是利用yum进行安装。。否则会崩溃的

4、编译

新建一个临时路径来保存编译的结果,如下所示:

[root@FTP wxPython-src-3.0.2.0]# mkdir bld
[root@FTP wxPython-src-3.0.2.0]# cd bld
[root@FTP bld]# ../configure --prefix=/usr/local/pythonwxpython --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

新建bld来保存编译的结果,主要是由于编译的时候,占用的空间有1G多,所以需要用一个新的目录进行编译,注意上面configure前面有两个点。

编译结果如下:

进行安装:

make && make install

消耗的时间和占用的空间如下:--编译需要8分钟的样子,估计服务器会快很多

[root@FTP local]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_ftp-lv_root
9.9G 6.1G 3.3G 66% /
tmpfs 387M 0 387M 0% /dev/shm
/dev/sda1 485M 32M 428M 7% /boot
[root@FTP local]# date
Tue Apr 5 13:07:07 EDT 2016
[root@FTP local]# date
Tue Apr 5 13:14:56 EDT 2016
[root@FTP local]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_ftp-lv_root
9.9G 8.1G 1.3G 87% /
tmpfs 387M 0 387M 0% /dev/shm
/dev/sda1 485M 32M 428M 7% /boot

进行安装wxpython:--WX_CONFIG就是前面编译configure的路径

[root@FTP wxPython]# python setup.py build_ext --inplace --debug WX_CONFIG=/usr/local/pythonwxpython/bin/wx-config

安装之后,设置wxpython的环境变量:

export PYTHONPATH="/usr/local/wxPython"
export LD_LIBRARY_PATH="/usr/local/pythonwxpython/lib

可以添加在用户加目录中,另外必须将wxpython添加到pythonpath中,如下:

[root@FTP wxPython-src-3.0.2.0]# cp -r wxPython /usr/local/wxPython/

拷贝主要是为了对应上面的PYTHONPATH

问题

1、重新编译

在进行重新编译的时候,必须先进行清除前面编译的文件,使用的命令如下:

make distclean

如果使用makeclean,是不可以的,报错信息如下:

configure: error: source directory already configured; run "make distclean" there first
configure: error: ../../../src/tiff/configure failed for src/tiff

如果使用上面的命令不能清除,那么还是重新解压进行编译吧

2、导入wx模块出错

导入wx模块的时候,出错,出错内容如下:

>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "wx/__init__.py", line 45, in <module>
from wx._core import *
File "wx/_core.py", line 4, in <module>
import _core_
ImportError: libwx_gtk2u_xrc-3.0.so.0: cannot open shared object file: No such file or directory

设置环境变量LD_LIBRARY_PATH:

[root@FTP wxPython]# cat ~/.bash_profile |grep LD
export LD_LIBRARY_PATH="/usr/local/pythonwxpython/lib

将环境变量写在用户文件中,从而每次都可以直接使用。

3、在别的路径无法导入wx模块

在别的路径导入wx模块的时候,报错如下:

[root@FTP ~]# python
Python 2.7.11 (default, Apr 5 2016, 12:30:11)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wx

主要是将wxpython加入到模块的搜索路径中,只要修改环境变量即可,如下:

[root@FTP wxPython-src-3.0.2.0]# cp -r wxPython /usr/local/wxPython
[root@FTP wxPython-src-3.0.2.0]# cat ~/.bash_profile |grep PYTHON
export PYTHONPATH="/usr/local/wxPython"

4、报错gtk未找到

具体的报错内容如下:

*** Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GTK+ is incorrectly installed.
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.

主要查看是否安装了gtk2和gtk2-devel包,安装上这两个包即可

有人说需要安装pkgconfig包,本系统中已经安装了这个包,所以未进行测试。

5、报错gstream未找到

具体的报错内容如下:

configure: No package 'gstreamer-1.0' found
configure: error: no gstreamer-1.0 >= 1.0.0 (GStreamer) found

主要报错是因为缺少几个包,具体的包如下:

[root@FTP demo]# rpm -qa |grep ^gstreamer*
gstreamer-plugins-base-0.10.29-1.el6.x86_64
gstreamer-0.10.29-1.el6.x86_64
gstreamer-devel-0.10.29-1.el6.x86_64
gstreamer-plugins-base-devel-0.10.29-1.el6.x86_64
gstreamer-tools-0.10.29-1.el6.x86_64

看缺少什么包,然后就安装什么依赖包。

6、报错opengl库未找到

具体的报错内容如下:

configure: error: OpenGL libraries not available

主要缺少的依赖库如下:

[root@FTP demo]# rpm -qa|egrep "mesa-libGL-devel|mesa-libGLU-devel"
mesa-libGL-devel-7.11-3.el6.x86_64
mesa-libGLU-devel-7.11-3.el6.x86_64

注意没有带devel的包也要相应的装上。

7、在进行安装wxpython的时候出现很多报错

在进行安装wxpython的时候,如果出现很多编译错误,直接加上参数BUILD_GLCANVAS=0,也可以直接忽略。

[root@FTP wxPython]# python setup.py build_ext --inplace --debug WX_CONFIG=/usr/local/pythonwxpython/bin/wx-config BUILD_GLCANVAS=0

8、其他的问题

如果出现其他的问题的话,基本都是依赖包的问题,依次进行安装上述的依赖包即可。

使用源码编译wxpython-基于python2.7的更多相关文章

  1. Ubuntu 环境 TensorFlow (最新版1.4) 源码编译、安装

    Ubuntu 环境 TensorFlow 源码编译安装 基于(Ubuntu 14.04LTS/Ubuntu 16.04LTS/) 一.编译环境 1) 安装 pip sudo apt-get insta ...

  2. 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机

    实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) apache版本: apache2.2.27 mysql版本:  Mysql-5.6.23 php版本 ...

  3. 基于cdh5.10.x hadoop版本的apache源码编译安装spark

    参考文档:http://spark.apache.org/docs/1.6.0/building-spark.html spark安装需要选择源码编译方式进行安装部署,cdh5.10.0提供默认的二进 ...

  4. 基于源码编译安装openssh

     最近的,openssl/openssh等相继漏洞的暴露,让暴露在公网的linux.沦陷为肉鸡的正营... 没办法,还是升级版本... 00.openssh简介 OpenSSH 是一组安全远程的连接工 ...

  5. TensorFlow Python2.7环境下的源码编译(三)编译

    一.源代码编译 这里要为仅支持 CPU 的 TensorFlow 构建一个 pip 软件包,需要调用以下命令: $ bazel build --cxxopt="-D_GLIBCXX_USE_ ...

  6. golang基于当前1.9版本进行源码编译升级到1.10

    一.起因 golang出了最新的1.10版本,而刚出的vgo也是需要基于该最新版本的.为了测试vgo,因此需要将我的v1.9升级到v1.10版本. 安装过golang的同学都知道,golang常用的有 ...

  7. 源码编译安装python2/3版本

    1- 源码编译安装python2.7版本 1.1- 下载源码包 wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz 1.2- ...

  8. 基于源码编译的lnmp架构实现论坛的搭建及memcache的应用

    系统环境: RHEL6 x86-64 selinux and iptables disabled LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构 Linux是一类 ...

  9. 源码编译安装MySQL8.0.20

    1 概述 本文章主要讲述了如何从源码编译安装MySQL社区版8.0.20,首先会介绍一些编译安装的相关知识,然后开始编译安装 2 源码编译安装的相关知识 2.1 make与configure make ...

随机推荐

  1. git merge简介【转】

    转自:http://blog.csdn.net/hudashi/article/details/7664382 git merge的基本用法为把一个分支或或某个commit的修改合并现在的分支上.我们 ...

  2. Android 判断用户2G/3G/4G移动数据网络

    Android 判断用户2G/3G/4G移动数据网络 在做 Android App 的时候,为了给用户省流量,为了不激起用户的愤怒,为了更好的用户体验,是需要根据用户当前网络情况来做一些调整的,也可以 ...

  3. [原]zoj3772--【水题】线段树区间查询+矩阵乘法

    思路来源:http://blog.csdn.net/u013654696/article/details/23037407#comments [做浙大校赛的时候没有看这道题,事后做的.思路不是自己的, ...

  4. 《OD学Sqoop》数据转换工具Sqoop

    一. 第二阶段课程回顾 hadoop 2.x HDFS YARN MapReduce Zookeeper Hive 二.大数据协作框架 对日志类型的海量数据进行分析 hdfs mapreduce/hi ...

  5. Mysql中的Prepared Statement与Stored Precedure学习

    可以参考: http://stackoverflow.com/questions/196652/prepared-statement-vs-stored-procedure They are not ...

  6. hdu 4405 Aeroplane chess(简单概率dp 求期望)

    Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  7. 【笨嘴拙舌WINDOWS】实践检验之按键精灵【Delphi】

    通过记录键盘和鼠标位置和输入信息,然后模拟发送,就能够创建一个按键精灵! 主要代码如下: library KeyBoardHook; { Important note about DLL memory ...

  8. Spring MVC 下index.jsp访问

    spring-mvc.xml配置 <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 --> <bean class="org.springframework.we ...

  9. UVa 1611 (排序 模拟) Crane

    假设数字1~i-1已经全部归位,则第i到第n个数为无序区间. 如果i在无序区间的前半段,那么直接将i换到第i个位置上. 否则先将i换到无序区间的前半段,再将i归位.这样每个数最多操作两次即可归位. # ...

  10. Jenkins+Maven+SVN搭建自动部署、自动测试环境

    .打开http://10.3.15.78:8080/jenkins/,第一次进入里面没有数据,我们需要创建job,我们这有2个项目,需要创建2个job.http://10.3.34.163:9890/ ...