我正在尝试在我的 Ubuntu 18.04 机器上安装 wxPython 4。
sudo pip install wxpython
我首先收到此警告
The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
最终出现错误
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-SyaTU1/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-bzIjlK/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-SyaTU1/wxpython/
我在使用 wxPython3 时遇到了类似的问题,解决办法是使用 get 安装它
sudo apt-get install python-wxgtk-3.0
我还能够为 Python 3 安装 wxPython 4,但不能为 Python 2.7 安装(指示)
另外,我很困惑为什么安装 wxpython 需要这么多 CPU
sudo pip install wxpython
答案1
等待足够长的时间后,该过程完成,我安装了 wxPython 4。
跑步
sudo apt install make gcc libgtk-3-dev libwebkitgtk-dev libwebkitgtk-3.0-dev libgstreamer-gl1.0-0 freeglut3 freeglut3-dev python-gst-1.0 python3-gst-1.0 libglib2.0-dev ubuntu-restricted-extras libgstreamer-plugins-base1.0-dev
sudo pip install wxpython
或者sudo pip3 install wxpython
等待一段时间才能安装
完成后,您将看到此消息。
The directory '/home/user-ii-6/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user-ii-6/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting wxpython
Downloading https://files.pythonhosted.org/packages/dd/31/bd55ab40e406a026a7fda0bb5eb61f466682544ae91ac26267c750f5e618/wxPython-4.0.3.tar.gz (68.5MB)
100% |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 68.5MB 929kB/s
Requirement already satisfied: six in ./.local/lib/python2.7/site-packages (from wxpython) (1.11.0)
Requirement already satisfied: PyPubSub in ./.local/lib/python2.7/site-packages (from wxpython) (4.0.0)
Requirement already satisfied: typing in ./.local/lib/python2.7/site-packages (from PyPubSub->wxpython) (3.6.6)
Installing collected packages: wxpython
Running setup.py install for wxpython ... done
Successfully installed wxpython-4.0.3
答案2
由于发行版和 wx 端口(GTK2 或 GTK3)有多种选择,因此文件不能全部位于同一文件夹中,以便 pip 轻松访问。这只是意味着您需要进一步深入研究才能找到要提供给 pip 的 URL。例如,要获取适用于 Ubuntu 18.04(以及 16.10、LinuxMint 18 以及可能的其他版本)的 GTK3 wxPython 版本,您可以使用如下 pip 命令:
pip 安装 -U \ -fhttps://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04\ wxPython
当然,您也可以自行下载 wheel 文件,然后使用 pip 安装该文件的本地副本。
答案3
我首先通过以下方式找到它:
sudo apt search python3-wx
我安装了最新的 wxpython:
sudo apt-get install python3-wxgtk4.0 python3-wxgtk-webview4.0 python3-wxgtk-media4.0
如果愿意的话,您也可以尝试使用 synaptic 的方式来安装它。
答案4
如果有人修改了这个错误
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
尝试这个
sudo apt install make gcc libgtk-3-dev libwebkitgtk-dev libwebkitgtk-3.0-dev libgstreamer-gl1.0-0 freeglut3 freeglut3-dev python-gst-1.0 python3-gst-1.0 libglib2.0-dev ubuntu-restricted-extras libgstreamer-plugins-base1.0-dev
sudo apt-get install python-wxgtk3.0