目录
Ubuntu20安装wxPython
centos7/Ubuntu20,python版本3.8,需要安装robotframework-ride 或者 wxPython
在安装wxpython时报错,切换python版本,使用pip或手动安装wxpython都出现如下错误:
copying wx/html2.pyi -> build/lib.linux-x86_64-3.8/wx
copying symlink wx/libwx_baseu-3.0.so -> build/lib.linux-x86_64-3.8/wx/libwx_baseu-3.0.so
error: [Errno 2] No such file or directory: 'build/lib.linux-x86_64-3.8/wx/libwx_baseu-3.0.so'
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-p1agpt0t/wxPython/setup.py'"'"'; __file__='"'"'/tmp/pip-install-p1agpt0t/wxPython/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-0tmrq3qv/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/wxPython Check the logs for full command output.
python3.8默认的setuptools都是50左右的版本,将setuptools回退到41.0.1可以解决问题。
pip install setuptools==41.0.1
pip install wxPython==4.0.7 或者pip install robotframework-ride
另外还需安装下面的工具与开发包:
apt install make gcc libgtk-3-dev libgstreamer-gl1.0-0 freeglut3 freeglut3-dev python3-gst-1.0 libglib2.0-dev ubuntu-restricted-extras libgstreamer-plugins-base1.0-dev build-essential libsdl2-dev libwebkit2gtk-4.0-dev libssl-dev
Ubuntu24.04安装wxPython
Ubuntu24默认安装的Python版本是3.12。
安装wxPython需要先安装python3-pip。
apt install -y python3-pip
另外还需安装以下的包:
apt install -y make gcc g++
apt install -y libwebkit2gtk-4.1-dev
apt install -y libgstreamer-plugins-base1.0-dev
apt install -y libglib2.0-dev
apt install -y python3-gst-1.0
apt install -y libgtk-3-dev
apt install -y libgstreamer-gl1.0-0
apt install -y freeglut3-dev
apt install -y libsdl2-dev
apt install -y libssl-dev
apt install -y ubuntu-restricted-extras
apt install -y build-essential
配置pip的源为国内的源,临时使用国内源:
pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple/
# 阿里云镜像
# https://mirrors.aliyun.com/pypi/simple/
# 中国科技大学镜像
# https://pypi.mirrors.ustc.edu.cn/simple/
# 豆瓣(中国的)镜像
# http://pypi.douban.com/simple/
# 清华大学镜像
# https://pypi.tuna.tsinghua.edu.cn/simple/
永久设置默认源:
在 Windows 上,你可以找到 pip
的配置文件 pip.ini
(或在 Unix 和 macOS 上是 pip.conf
),通常位于以下位置之一:
-
Windows:
%APPDATA%\pip\pip.ini
-
Unix 和 macOS:
~/.config/pip/pip.conf
或~/.pip/pip.conf
你可以在pip.ini / pip.conf中添加或修改以下内容来设置默认源:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
然后再用pip安装wxPython:
pip install wxPython