【发布时间】:2020-06-11 04:15:16
【问题描述】:
目标:在Ubuntu 18.04下将pyqt5导入python3
我知道这里和其他地方有很多类似问题的答案。我已经尝试了很多,但我没有看到任何与我的情况完全匹配的东西。
从全新安装 Ubuntu 18.04 开始,我尝试了很多方法来让语句 import pyqt5 在 Python 3.6.9 中成功,这是此发行版上的默认 python3。
他们都没有成功。
在几次尝试中,重新安装 Ubuntu 几次,我让 pip3 遇到 404 下载 https://pypi.org/simple/python3-pyqt5/ 并通过将 URL 粘贴到 Firefox 中确认错误并获得 404。(我还检查了 Firefox 工作正常上网)
但通常我运行的过程似乎表明 pyqt 已成功加载,但仍无法在 Python3 中导入。
我从各种网站尝试过的方法包括:
- pip3 install --upgrade pip
- pip3 install pyqt5==5.14.0 vs pip3 install pyqt5(默认为5.14.1)
- 安装一个简单的pypi模块,发现可以毫无问题地导入Python3
- 在 sudo 下运行 pip3
- 将 python3 升级到 Python 3.7.4
下面显示了我从重新安装开始所做的更完整的列表。
对解决方案或在我的系统上查看什么有任何建议?
我上周通过从 Ubuntu.com 下载可执行文件创建了一个 Ubuntu 18.04.4 的可启动记忆棒。与该版本打包的所有内容似乎都可以正常工作,包括其他情况下的 Python 3.6.9。除了以下步骤,我几乎什么都不做。
sudo apt install python3-pip
pip3 install humanfriendly (just to ensure that pip3 works for a simply pypi module)
pip3 install --upgrade pip
pip3 install python3-pyqt5
sudo apt-get install pyqt5-dev-tools (no complaints from pip3 seems to work okay)
sudo apt-get install qttools5-dev-tools (seems to work)
in python3
>>>import pyqt5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyqt5'
pip3 uninstall pyqt5 (Successfully uninstalled PyQt5-5.14.0)
pip3 install pyqt5 --user (Successfully installed pyqt5-5.14.1
Try to import in python3 again, same result: "No module named 'pyqt5'"
cd ~/.local/bin
ls
humanfriendly pip pip3 pip3.6 pylupdate5 pyrcc5 pyuic5
(there seems not to be an entry for pyqt5 although there is for some of its stand-alone componentes)
pip3 uninstall pyqt5
ls
humanfriendly pip pip3 pip3.6
(what was there went away)
pip3 uninstall pyqt5 (Successfully uninstalled PyQt5-5.14.1)
pip3 install pyqt5 --user (seems to succeed)
try to import in python3 (same error)
pip3 uninstall pyqt5 (Successfully uninstalled PyQt5-5.14.1)
next I tried sudo pip3 uninstall pyqt5
seems to work; not importable in python3; sudo pip3 uninstall
next I created a virtual env, ~/.vents/tevs
activate the venv
pip3 install pyqt5==5.14.0
Installing collected packages: PyQt5-sip, pyqt5
attempt to import pyqt5 in python3: fails as before
pip3 uninstall pyqt5
(Successfully uninstalled PyQt5-5.14.0 after listing thousands of files
in .venvs/tevs/lib/python3.6/site-packages/PyQt5)
pip3 install python3-pyqt5
(fails with HTTP Error: 404 Client Error:
Not Found for url: https://pypi.org/simple/python3-pyqt5/)
【问题讨论】:
标签: python python-3.x pyqt pyqt5 ubuntu-18.04