程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

關於Python安裝PyQT5相關庫PyQT5-tools安裝失敗版本不適配的問題

編輯:Python

最近想要用Python做界面程序的開發,研究了下,主流是使用PyQT5相關庫來開發,於是就開始了PyQT5相關庫的安裝。本以為安裝一個庫而已,這不是Python開發者手到擒來的事嗎,so easy啦!

但是,結果卻是,一直報錯安裝不了!!!

在PyCharm集成環境安裝報錯如下:

ERROR: Could not find a version that satisfies the requirement pyqt5-tools (from versions: none)

在終端執行命令執行報錯如下:

E:\PythonProject> pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pyqt5-tools
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/70/a25aab849a5e38ae78716acde1f917a14d9d819c8600bbb8cf536781f7c5/pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB)
Requirement already satisfied: click in c:\users\謝強華\appdata\local\programs\python\python310\lib\site-packages (from pyqt5-tools) (8.1.3)
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/36/b8/a255b8160e863678aa7d559a4c8c33b5448a6e270992d1464ec9f87ed633/pyqt5_tools-5.15.4.3.1-py3-none-any.whl (28 kB)
Collecting python-dotenv
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/30/5f/2e5c564bd86349fe6b82ca840f46acf6f4bb76d79ba9057fce3d3e008864/python_dotenv-0.20.0-py3-none-any.whl (17 kB)
Collecting pyqt5==5.15.4
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/8e/a4/d5e4bf99dd50134c88b95e926d7b81aad2473b47fde5e3e4eac2c69a8942/PyQt5-5.15.4.tar.gz (3.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
main()
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 160, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\api.py", line 46, in build_wheel
project = AbstractProject.bootstrap('wheel',
File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 87, in bootstrap
project.setup(pyproject, tool, tool_description)
File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\project.py", line 584, in setup
self.apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-install-hq9cgjio\pyqt5_8974b6d63c12423293bc5134d3deaf3a\project.py", line 63, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\sipbuild\project.py", line 236, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-build-env-6vjbslli\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
PS E:\PythonProject> pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pyqt5-tools
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/70/a25aab849a5e38ae78716acde1f917a14d9d819c8600bbb8cf536781f7c5/pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB)
Collecting pyqt5==5.15.4
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/8e/a4/d5e4bf99dd50134c88b95e926d7b81aad2473b47fde5e3e4eac2c69a8942/PyQt5-5.15.4.tar.gz (3.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
main()
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 160, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\api.py", line 46, in build_wheel
project = AbstractProject.bootstrap('wheel',
File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 87, in bootstrap
project.setup(pyproject, tool, tool_description)
File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\project.py", line 584, in setup
self.apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-install-ob1rwhpk\pyqt5_7075254d94fa405cb583cb1806e431da\project.py", line 63, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults
super().apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\sipbuild\project.py", line 236, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "C:\Users\\AppData\Local\Temp\pip-build-env-t0u6llqw\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

下載wheel 終端執行命令報錯如下:

PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.15.0.1.7.1-cp35-cp35m-win_amd64.whl
ERROR: pyqt5_tools-5.15.0.1.7.1-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform.
PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl
ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform.
PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.3-cp35-none-win32.whl
ERROR: pyqt5_tools-5.10.1.1.3-cp35-none-win32.whl is not a supported wheel on this platform.
PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl
ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform.
PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl
ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform.
PS E:\PythonProject> pip install F:\桌面\pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl
ERROR: pyqt5_tools-5.10.1.1.4rc0-cp35-none-win_amd64.whl is not a supported wheel on this platform.
PS E:\PythonProject>

一直都是版本不適配的問題。

OK!那就安裝低版本的Python解釋器!


我依次降低了Python解釋器的版本。重復以上操作,還是依舊報錯。。。。

算了吧!

放棄吧!

還是用Java開發 用C語言開發吧


。。。

。。。。

。。。。。

還是再努力一下吧,我覺得我悟了

我翻看了很多博客,看到了這樣一個解決方案

我嘗試了一下。我用Python3.6版本的解釋器。我先安裝了 wheel

然後再安裝PyQT5-tools

然後竟然成功安裝了哦!!!


然後 開始配置 Qt Designer

配置 PyUIC

配置PyRCC

OK!
測試一下

打開了。

就是這麼完美。

寫個Hello World 試試。

創建一個測試項目

打開新窗口

右鍵代開 Designer

然後創建一個 weidge 窗口。

拖入一個lable顯示標簽

標簽寫 Hello World


保存命名為 HelloWorld.iu

用PyUIC打開保存的文件

生成一個 HelloWorld.py的文件

修改一下mian.py 調用HelloWorld.py

import sys
import HelloWorld
from PyQt5.QtWidgets import QApplication, QMainWindow
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = HelloWorld.Ui_Form()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

執行一下

哦吼。報錯了。

放棄

擺爛

這個問題沒有找到解決方案
。。。

。。。。。
。。。。。。。

問題總結

前面的PyQT5-tools 一直安裝失敗是因為 wheel 庫沒有安裝

先安裝wheel 庫 然後再安裝 PyQT5相關的庫就沒問題了

當然3.10版本的解釋器是安裝不了了 PyQT5-tools 不支持

我試過了

Python3.8 Python 3.6 是沒有問題的


至於最後測試還是報錯 執行不了 這個問題

我不知道

庫是安裝了

Designer 能打開了

最後一步究竟是錯在哪了呢?

按照網友們的建議 我把platforms 文件夾放在同級目錄了

但是 還是報錯的


我敏銳的發現 我這邊報錯跟網友們的是有差別的 網友們左上角顯示的是Designer

我報錯的左上角是 Python

大概是這樣子吧 所以我看了網友們的方法 還是解決不了我這個問題

就這樣吧


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved