[英]ImportError with PySide6/shiboken6
I'm trying to get PySide6 to run in Python 3.8.0.我试图让 PySide6 在 Python 3.8.0 中运行。 Installation went fine:安装顺利:
C:\>pip install pyside6
Collecting pyside6
Using cached PySide6-6.0.0-6.0.0-cp36.cp37.cp38.cp39-none-win_amd64.whl (62.4 MB)
Collecting shiboken6==6.0.0
Using cached shiboken6-6.0.0-6.0.0-cp36.cp37.cp38.cp39-none-win_amd64.whl (2.3 MB)
Installing collected packages: shiboken6, pyside6
Successfully installed pyside6-6.0.0 shiboken6-6.0.0
but i'm hit with an import error:但我遇到了导入错误:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySide6
PySide6/__init__.py: Unable to import shiboken6 from , C:\Python38\python38.zip, C:\Python38\DLLs, C:\Python38\lib, C:\Python38, C:\Python38\lib\site-packages
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python38\lib\site-packages\PySide6\__init__.py", line 107, in <module>
_setupQtDirectories()
File "C:\Python38\lib\site-packages\PySide6\__init__.py", line 57, in _setupQtDirectories
import shiboken6
File "C:\Python38\lib\site-packages\shiboken6\__init__.py", line 25, in <module>
from .shiboken6 import *
ImportError: DLL load failed while importing shiboken6: The specified procedure could not be found.
What did i do wrong?我做错了什么?
What did i do wrong?我做错了什么?
I don't believe you did anything wrong.我不相信你做错了什么。
I think this was a known bug in shiboken6
versions <=6.0.0
.我认为这是shiboken6
版本<=6.0.0
中的一个已知错误。 It was reported partly in the PySide
bug tracker: PYSIDE-932 .它在PySide
错误跟踪器中部分报告: PYSIDE-932 。
The issue appeared to be that they were attempting to import from a zip
file.问题似乎是他们试图从zip
文件导入。 From the comments in version 6.3.0
of shiboken6.__init__
:来自shiboken6.__init__
6.3.0
的评论:
# PYSIDE-932: Python 2 cannot import 'zipfile' for embedding while being imported, itself.
# We simply pre-load all imports for the signature extension.
# Also, PyInstaller seems not always to be reliable in finding modules.
# We explicitly import everything that is needed:
The comment says Python 2 cannot import
, but it should read PySide2 cannot import
because the issue came from Python 3.6
using PySide 2
.评论说Python 2 cannot import
,但它应该阅读PySide2 cannot import
因为问题来自Python 3.6
using PySide 2
。
The Qt Docs mention using a newer version of virtualenv
to fix this problem, but I do not believe virtualenv
is the culprit. Qt 文档提到使用较新版本的virtualenv
来解决此问题,但我不相信virtualenv
是罪魁祸首。 Moreover, the latest Python 3
versions ship with and use venv
.此外,最新的Python 3
版本附带并使用venv
。 Instead, I believe this was an issue with importing zip
files.相反,我认为这是导入zip
文件的问题。 It may have been resolved when Barry Warsaw/Brett Cannon and their team introduced importlib.resources
in newer versions of Python 3
, which can particularly help with zip files.当 Barry Warsaw/Brett Cannon 和他们的团队在较新版本的Python 3
中引入importlib.resources
时,它可能已经解决,这对 zip 文件特别有帮助。
See their talk here:在这里查看他们的谈话:
Barry Warsaw - Get your resources faster, with importlib.resources - PyCon 2018 Barry Warsaw - 使用 importlib.resources 更快地获取资源 - PyCon 2018
Ultimately, I believe this was resolved in the latest version of shiboken6
(ie 6.3.0
).最终,我相信这在最新版本的shiboken6
(即6.3.0
)中得到了解决。
Give that a try and see if that works.试一试,看看是否可行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.