我最近在 openSuSE 15.4 上从源代码安装了 Python 3.10.11,因为 SuSE 附带的 Python 版本太旧了(3.6)。现在我需要添加几个模块,其中一个是,正如我想要设置的wxPython>=4.1.1
应用程序 () 的要求中所述。正在安装……displaycal-python3
wxPython
(displaycal) ╭─jacek@epica ~/bin/tmp/Python-3.10.11/dist/displaycal/displaycal-py3 ‹develop*›
╰─➤ pip install wxPython 1 ↵
…由于一个奇怪的错误而没有成功:
Setting top to : /tmp/pip-install-jrczxi29/wxpython_b642a422084843e69dbbbbd05cef236e
Setting out to : /tmp/pip-install-jrczxi29/wxpython_b642a422084843e69dbbbbd05cef236e/build/waf/3.10/gtk3
Checking for 'gcc' (C compiler) : /usr/bin/gcc
Checking for 'g++' (C++ compiler) : /usr/bin/g++
Checking for program 'python' : /home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/bin/python
Checking for python version >= 3.7.0 : 3.10.11
python-config : not found
Checking for library python3.10 in LIBDIR : yes
Checking for header Python.h : Distutils not installed? Broken python installation? Get python-config now!
The configuration failed
(complete log in /tmp/pip-install-jrczxi29/wxpython_b642a422084843e69dbbbbd05cef236e/build/waf/3.10/gtk3/config.log)
Command '"/home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/bin/python" /tmp/pip-install-jrczxi29/wxpython_b642a422084843e69dbbbbd05cef236e/bin/waf-2.0.24 --wx_config=/tmp/pip-install-jrczxi29/wxpython_b642a422084843e69dbbbbd05cef236e/build/wxbld/gtk3/wx-config --gtk3 --python="/home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/bin/python" --out=build/waf/3.10/gtk3 configure build ' failed with exit code 1.
Finished command: build_py (0m1.50s)
Finished command: build (1m22.114s)
Command '"/home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/bin/python" -u build.py build' failed with exit code 1.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for wxPython
Running setup.py clean for wxPython
Failed to build wxPython
ERROR: Could not build wheels for wxPython, which is required to install pyproject.toml-based projects
我不知道为什么pip
找不到python-config
,因为它已经在我的计算机上了:
(displaycal) ╭─jacek@epica ~/bin/tmp/Python-3.10.11/dist/displaycal/displaycal-py3 ‹develop*›
╰─➤ pip install python-config 1 ↵
Requirement already satisfied: python-config in /home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/lib/python3.10/site-packages (0.1.2)
根据旧问题的提示Distutils 找不到 Python.h:
(displaycal) ╭─jacek@epica ~/bin/tmp/Python-3.10.11/dist/displaycal/displaycal-py3 ‹develop*›
╰─➤ export C_INCLUDE_PATH=/home/jacek/bin/tmp/Python-3.10.11/Include:C_INCLUDE_PATH
(displaycal) ╭─jacek@epica ~/bin/tmp/Python-3.10.11/dist/displaycal/displaycal-py3 ‹develop*›
╰─➤ export CPLUS_INCLUDE_PATH=/home/jacek/bin/tmp/Python-3.10.11/Include:CPLUS_INCLUDE_PATH
…也没有帮助。那么:我怎样才能知道位于pip
哪里Python.h
(事实上,它位于/home/jacek/bin/tmp/Python-3.10.11/Include
)并克服这个构建错误?
更新:我发现pip.conf
我使用的虚拟环境中缺少该文件。所以我写了一个:
[global]
default-timeout = 60
respect-virtualenv = true
download-cache = /tmp
log-file = /tmp/pip-log.txt
include-dirs = /home/jacek/bin/tmp/Python-3.10.11/Include/cpython:/home/jacek/bin/tmp/Python-3.10.11/Include
…然后第二次运行安装命令。但现在我收到一个错误,没有任何消息,甚至没有任何痕迹:
(displaycal) ╭─jacek@epica ~/bin/tmp/Python-3.10.11/dist/displaycal/displaycal-py3 ‹develop*›
╰─➤ pip install wxPython 1 ↵
Collecting wxPython
Using cached wxPython-4.2.0.tar.gz (71.0 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: pillow in /home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/lib/python3.10/site-packages (from wxPython) (9.5.0)
Requirement already satisfied: six in /home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/lib/python3.10/site-packages (from wxPython) (1.16.0)
Requirement already satisfied: numpy in /home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/lib/python3.10/site-packages (from wxPython) (1.24.3)
Building wheels for collected packages: wxPython
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Building wheel for wxPython (setup.py) ... error
ERROR: Failed building wheel for wxPython
Running setup.py clean for wxPython
Failed to build wxPython
ERROR: Could not build wheels for wxPython, which is required to install pyproject.toml-based projects
进一步的调查发现了这样的错误信息:
self.initialize_options()
error: can't copy '/home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/displaycal-py3/DisplayCAL/../dist/net.displaycal.DisplayCAL.appdata.xml': doesn't exist or not a regular file
更新 #2:
消息中提到的 XML 文件确实存在,但在另一个目录中:/home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/displaycal-py3/misc
因此我创建了一个符号链接并重新运行pip
。 XML 文件不再是问题,但缺失的文件Python.h
仍然存在:
python-config : /home/jacek/bin/tmp/Python-3.10.11/dist/displaycal/bin/python-config
Checking for library python3.10 in LIBDIR : yes
Checking for header Python.h : Distutils not installed? Broken python installation? Get python-config now!
The configuration failed
Python.h 当然存在于我的 Python 安装中:/home/jacek/bin/tmp/Python-3.10.11/Include
将头文件的路径传递给 venv actator 是没有帮助的 — — 就像这样:
╭─jacek@epica ~/bin/tmp/Python-3.10.11/dist/displaycal/bin
╰─➤ source activate --cflags="-I/home/jacek/bin/tmp/Python-3.10.11/Include"
那么:我该如何告诉pip
、、wheel
venv 或任何人添加/home/jacek/bin/tmp/Python-3.10.11/Include
到包含文件路径??
答案1
查看这些帖子,我也遇到了这个问题。希望你现在已经解决了,但以防万一:
https://github.com/wxWidgets/Phoenix/issues/2297 https://www.pixelstech.net/article/1599647177-Problem-and-Solution-for-Installing-wxPython-on-Ubuntu-20-04
我正在运行 wsl Ubuntu 22.04 Python 3.11