conda pyqt导入在新的虚拟环境中失败

时间:2018-04-14 04:40:26

标签: import virtualenv pyqt5 conda

我尝试使用pyqt运行程序。

如果我没有使用虚拟环境,但是如果我激活了虚拟环境,那么它会失败:ImportError:DLL加载失败...

Traceback (most recent call last):
  File "submitA2.py", line 14, in <module>
    import matplotlib.pyplot as plt
  File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\pyplot.py", line 116, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\__init__.py", line 60, in pylab_setup
    [backend_name], 0)
  File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 16, in <module>
    from .backend_qt5 import (
  File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\backend_qt5.py", line 18, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 20, in <module>
    import matplotlib.backends.qt_editor.formlayout as formlayout
  File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_editor\formlayout.py", line 56, in <module>
    from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
  File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_compat.py", line 137, in <module>
    from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: DLL load failed: The specified procedure could not be found.

我无法在此虚拟环境中安装另一个pyqt软件包,因为它告诉我:

# All requested packages already installed.
# packages in environment at C:\Users\jerem\Anaconda3\envs\deep:
#
pyqt                      5.6.0                    py36_4    conda-forge

如何解决这个问题?感谢。

2 个答案:

答案 0 :(得分:1)

Jeremy Chen的解决方案是唯一对我有用的解决方案。即

LSTM在您的conda环境中

在互联网上列出的所有其他solutinos均无效。 但是,安装pytqt = 5.9会在尝试

时使用以下错误中断matplotlib模块

conda install pyqt=5.9

  

ImportError:无法导入名称“ get_backend”

此问题通过使用

解决

import matplotlib

然后重新安装

conda uninstall matplotlib

答案 1 :(得分:0)

一个不完美的解决方案:安装不同版本的PyQt5似乎可以解决这个问题。

activate myenv
conda install pyqt=5.9