一、系统版本
二、安装wxPython-4.0.4.tar.gz
1、下载依赖
>sudo apt update
>sudo apt-get install build-essential libgtk-3-dev libwebkit2gtk-4.0-dev libssl-dev libcurl4-openssl-dev libgstreamer-plugins-base1.0-dev libnotify-dev freeglut3 freeglut3-dev libtiff-dev -y
2、安装wxPython
下载 wxPython-404 源代码,解压,进入解压目录:
构建python包:>python3 build.py build
安装:>sudo python3 build.py install
三、打成whl
(1)安装wheel
>pip install wheel
(2)打包
>python3 setup.py bdist_wheel
最终生成/home/wxPython-4.2.1/dist/wxPython-4.2.1-cp37-cp37m-linux_aarch64.whl
四、常见问题
1、debian自带python3.7.3可以源码安装wxPython,但使用源码安装的python无法源码安装wxPython,只能使用whl。
报错如下:
源码安装python版本 | wxPython版本 | 报错 |
3.6 | 4.0.4 | ERROR: failed building wxWidgets ---缺少依赖libtiff-dev |
3.6 | 4.0.4 | Command '"/usr/local/bin/python3" /home/wxPython-4.0.4/bin/waf-2.0.8 --wx_config=/home/wxPython-4.0.4/build/wxbld/gtk3/wx-config --gtk3 --python="/usr/local/bin/python3" --out=build/waf/3.6/gtk3 configure build ' failed with exit code 1. |
3.6 | 4.1.0 | The configuration failed (complete log in /home/wxPython-4.1.0/build/waf/3.6/gtk3/config.log) |
3.6 | 4.2.0 | Traceback (most recent call last): File "build.py", line 44, in <module> from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip, findCmd, \ File "/home/wxPython-4.2.0/buildtools/config.py", line 30, in <module> from attrdict import AttrDict ModuleNotFoundError: No module named 'attrdict' |
3.6 | 4.2.1 | The python version is too old, expecting (3, 7, 0) (complete log in /home/wxPython-4.2.1/build/waf/3.6/gtk3/config.log) |
2、系统自带python3.7安装wxpython-4.0.4或者wxpython-4.0.7,需要libtiff-dev包,否则报错:
ERROR: failed building wxWidgets
Traceback (most recent call last):
File "build.py", line 1321, in cmd_build_wx
wxbuild.main(wxDir(), build_options)
File "/home/wxPython-4.0.4/buildtools/build_wxwidgets.py", line 375, in main
"Error running configure")
File "/home/wxPython-4.0.4/buildtools/build_wxwidgets.py", line 85, in exitIfError
raise builder.BuildError(msg)
buildtools.builder.BuildError: Error running configure
Finished command: build_wx (0m8.583s)
Finished command: build (0m8.583s)
但安装wxPython-4.1.0,不需要这个包。