简体   繁体   English

在Anaconda上使用PySide2找不到QtCore模块

[英]QtCore Module not found using PySide2 on Anaconda

With a python file containing the two lines 使用包含两行的python文件

import PySide2
from PySide2 import QtCore

The execution from Anaconda Prompt on Windows 10 looks as follows Windows 10上Anaconda Prompt的执行如下所示

(base) c:\src\pyside2>python ps2-first.py
Traceback (most recent call last):
  File "ps2-first.py", line 2, in <module>
    from PySide2 import QtCore
ImportError: DLL load failed: The specified module could not be found.

So the first import executed correctly, but it couldn't find the QtCore module. 因此,第一次导入已正确执行,但找不到QtCore模块。

Background: 背景:

Installed PySide2 using 使用以下方法安装PySide2

(base) c:\src\pyside2>conda config --add channels conda-forge
(base) c:\src\pyside2>conda install pyside2

Which succeeded. 哪个成功了。 Also, versions of conda and python are shown here: 另外,这里显示了conda和python的版本:

(base) c:\src\pyside2>conda --version
conda 4.7.10

(base) c:\src\pyside2>python -V
Python 3.7.1

Checking for PySide 2 installation: 检查PySide 2安装:

(base) c:\src\pyside2>conda list pyside2
# Name                    Version                   Build  Channel
pyside2                   5.9.0a1          py37h0555040_0    conda-forge

This DLL is in the path: pyside2.cp37-win_amd64.dll 该DLL位于路径中:pyside2.cp37-win_amd64.dll

The problem can be that your project folder name is pyside2 and Windows is case insensitive. 问题可能是您的项目文件夹名称为pyside2而Windows区分大小写。 So it is possible that python interpreter try to search QtCore inside your project folder. 因此,python解释器可能会尝试在项目文件夹中搜索QtCore

If this not help please run python -v -c "from PySide2 import QtCore" and add log to your question. 如果这没有帮助,请运行python -v -c "from PySide2 import QtCore"并将日志添加到您的问题。

The other problem can be that some dependencies of pyside2.cp37-win_amd64.dll can be missed. 另一个问题可能是pyside2.cp37-win_amd64.dll某些依赖pyside2.cp37-win_amd64.dll可能会丢失。 then loading of this library also will fail. 那么该库的加载也会失败。 You can check dependencies of dll by dependencywalker . 您可以通过dependencywalker检查dll的依赖关系

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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