> 文章列表 > Windows10的Ubuntu上搭建Python3.11的wxPython4开发环境

Windows10的Ubuntu上搭建Python3.11的wxPython4开发环境

Windows10的Ubuntu上搭建Python3.11的wxPython4开发环境

第一步,现在windows10上安装Ubuntu 20.04.5 LTS;

第二步,下载Python3.11.2的源代码,然后编译安装;

第三步,下载pip安装工具;

第四步,安装wxPython

pip3 install -U wxPython

结果遇到错误——

ERROR: Command errored out with exit status 1:command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0o19_5fk/wxPython/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0o19_5fk/wxPython/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\\r\\n'"'"', '"'"'\\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-0o19_5fk/wxPython/pip-egg-infocwd: /tmp/pip-install-0o19_5fk/wxPython/Complete output (7 lines):Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-0o19_5fk/wxPython/setup.py", line 27, in <module>from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSONameFile "/tmp/pip-install-0o19_5fk/wxPython/buildtools/config.py", line 30, in <module>from attrdict import AttrDictModuleNotFoundError: No module named 'attrdict'----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

在网上搜索了一下,有说Python版本太高,要降到3.9.x;也有说要下载setuptools的。

pip install setuptools -U

结果提示

ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.

于是追加

pip install launchpadlib -U

成功安装了launchpadlib-1.11.0

结果还是一样的错误提示;我就不信邪了;换bing国际版搜索;找到wxpython内部论坛一个错误的讨论帖,看起来和我的问题有些类似。Can't install from sources wxpython 4.2.0a1 - python 3.10 - Mint 21 - #10 by tester - wxPython Users - Discuss wxPython前半段没什么关联性,往下Robin大神出来了。解决了帖子最初的问题,紧接着又有新人进来提了问题。之前的提问者变为了解答者。他给了这么一个建议:

Try to install attrdict3 :pip install attrdict3

这一下给我了新思路。Just do it!然后继续安装wxPython,但很快遇到新的问题;看起来此路走不通;继续搜索网页资料,在浩瀚的数字世界中寻找答案。也许有chatGPT协助能提高效率。不过这应该又会启动另一个大工作量项目。

之前的尝试思路经过验证,也不靠谱,又走回老路。

sudo pip3 install -U wxPython

由于晚上网速太慢,经过了一天才有了初步结果。结果——

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.wxPython from https://files.pythonhosted.org/packages/d9/33/b616c7ed4742be6e0d111ca375b41379607dc7cc7ac7ff6aead7a5a0bf53/wxPython-4.2.0.tar.gz#sha256=663cebc4509d7e5d113518865fe274f77f95434c5d57bc386ed58d65ceed86c7:Expected sha256 663cebc4509d7e5d113518865fe274f77f95434c5d57bc386ed58d65ceed86c7Got        0e8c3e99206c29f5c6b5cf7834a5750192b9540b152db6251bd48c217188815f

真的很令人抓狂呀!!!!

继续搜索国际信息;command line - How to install wxpython 4 ubuntu 18.04 - Ask Ubuntu
     

上看到一点线索

sudo apt search python3-wx
Sorting... Done
Full Text Search... Done
python3-wxgtk-media4.0/focal 4.0.7+dfsg-2build1 amd64Python 3 interface to the wxWidgets Cross-platform C++ GUI toolkit (wx.media)python3-wxgtk-webview4.0/focal 4.0.7+dfsg-2build1 amd64Python 3 interface to the wxWidgets Cross-platform C++ GUI toolkit (wx.html2)python3-wxgtk4.0/focal 4.0.7+dfsg-2build1 amd64Python 3 interface to the wxWidgets Cross-platform C++ GUI toolkit

于是输入如下指令

sudo apt-get install python3-wxgtk-media4.0 python3-wxgtk-webview4.0 python3-wxgtk4.0

然后又进入网络下载阶段;中间出现了

Fetched 764 kB in 6min 24s (1991 B/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/w/wxpython4.0/python3-wxgtk4.0_4.0.7+dfsg-2build1_amd64.deb  Connection failed [IP: 91.189.91.38 80]

按照提示apt-get update之后再次执行

sudo apt-get install python3-wxgtk-media4.0 python3-wxgtk-webview4.0 python3-wxgtk4.0

这次终于完整成功执行了。Done!

终于要开始我的wxPython之旅了!