简体   繁体   中英

ImportError: DLL load failed while importing QtCore, QtGUI

I just upgraded my Python to 3.8.3 and pyside2 to 5.15.0 and now it's showing me:

from PySide2 import QtCore, QtGui, QtWidgets
ImportError: DLL load failed while importing QtCore: The specified module could not be found.

My Environment variables are in the path and I have the latest version of both Python and PySide2 ...

Why is this happening?? I tried reinstalling PySide2 but nothing happens...

I think you failed to install it. Probably it collides something...

I updated PySide6.2.4 → 6.3.0 today. I run into this error again.

In my case, QtWidgets...

On windows, we usually have Local files and Roaming files.

My installation leads my files into Local files, but I don't know why, Roaming file also has python file. And the file has site-packages, naturally Pyside6.2.4 was in it. So I removed the python file in Roaming.

And then, I reinstalled PySide6. Installation itself is no problem, error didn't occur. (Because Local files already have python file which has site-packages containing Pyside6... installation had no effect.)

But I checked the installed folder, the number of files seemed to be less than usual... there are no characters like QtWidgets...

In spite of reinstalling again, the condition never changed.

I read commandline message carefully, I found out I installed other files at the same time. PySide6_Addons_6.3.0.dist-info, PySide6_Essentials-6.3.0.dist-info PySide6-6.3.0.dist-info. Because these files are not removed in the previous handling, installation seemed to be in vain.

So I deleted PySide6, PySide6_Addons_6.3.0.dist-info, PySide6_Essentials-6.3.0.dist-info PySide6-6.3.0.dist-info all.

After that, I reinstalled PySide6.3.0. My installation sucessed.


In general, if we downloaded a python, we would download from python.org

You can download it into any drive. If you download python, python automatically makes a Lib module at the same directory.

And then, you must set a pass for them. I don't make sure which directory to add, it will be necessary procedure. In my environment system path environment as follows: 在此处输入图像描述

Scripts module will be created for mainly command-script. For example, they will have pyside2-rcc.exe or pyside2-uic.exe, and pip.exe. I was warned when I made Qt-resource file because of the lack of path.

If you can't do pip, you may be able to do the same thing by writing py -m command in front of the pip command.

Moreover, if you installed PySide2 , you should install into the site-packages belonging to the same directory of python.exe. You go into the directory python.exe exists with command-prompt, you command pip the PySide2 module.(from.whl will be better) After that, site-packages module of the Lib module will get the PySide2 packages.

For the test, I recommend you boot Python IDE and write "from PySide2 import QtCore, QtWidgets, QtGui and other codes.

Even if you follow my introduction, you may have the same problem.In that case, it is possible to be a time for transition of some other environments.

For example, AFAIK, PySide6.0 couldn't use QtWebEngine .But with PySide6.2 makes it.

I ran into the same problem when I was using Spyder with Anaconda, and I couldn't find out what is the reason. I don't make sure whether QtWebEngine can be used with Spyder with PySide6.2 even now because Anaconda can't use PySide6.x yet.AFAIK, PySide5.15 couldn't use QtWebEngine.

At any rate, I think we should know the basic, minimal environment for using python & pyside.

Anaconda is very useful, but I had no exact knowledge about controling directories for python, I was very confused.Sometimes, there may be also the problem at the spider side. (In addition to it, Anaconda recommends conda, but I often want to use pip.)I couldn't distinguish where the problem was.It makes me more confused.I have been trying to solve this problem in only the Anaconda environment.

For that reason, I think this basic installation will be a good mark.If we can execute python with this basic environment, the problem is in your package controller.Otherwise, we cannot help waiting for the time to solve it.


I also ran into this problem.

I couldn't execute my code as it is.

When I update my Anaconda3 for python3.7.x to python3.8.3., and update my PySide2,

this error hannpened.

I have followed this solution:

https://bugreports.qt.io/browse/PYSIDE-1323

Thanks to this, I could unexpectedly do 'from PySide2 import QtCore, QtGui, QtWidgets' on the Anaconda Prompt, console.

Nonetheless, I have the same error on the spyder, IPython.

I couldn't understand why it is. I couldn't execute codes from Spyder, but I can execute from Anaconda Prompt...(It seems to me they are the same thing, on the surface at least.)

So, as my final way, I changed the current console to an external console.

It is just the same to be executed from Console Application attached by Windows. (>python module_name.py)

I could execute my file by this way... (But unvisible errors came!)

Until this bug is repaired, I execute my file by an external console.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM