解决编译器遇到的 ImportError: DLL load failed while importing xxx: 找不到指定的程序。

https://stackoverflow.com/questions/55875548/pyopenms-dll-load-failed-the-specified-procedure-could-not-be-found

具体报错如下

Connected to pydev debugger (build 203.7717.81)
======================================================================
Error when loading pyOpenMS libraries!
Libraries could not be found / could not be loaded.
Note: when using the Spyder IDE, this error may be triggered when
the 'Automatic' backend is used. Please change this in Tools ->
Preferences -> IPython -> Graphics to 'Inline'.
To debug this error, please run ldd (on linux) or dependency walker (on windows) on 
C:\ProgramData\Anaconda3\envs\dgl\lib\site-packages\pyopenms\pyopenms.so
======================================================================
======================================================================
python-BaseException
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\ProgramData\Anaconda3\envs\dgl\lib\site-packages\pyopenms\__init__.py", line 80, in <module>
    raise e
  File "C:\ProgramData\Anaconda3\envs\dgl\lib\site-packages\pyopenms\__init__.py", line 43, in <module>
    from .all_modules import *
  File "C:\ProgramData\Anaconda3\envs\dgl\lib\site-packages\pyopenms\all_modules.py", line 1, in <module>
    from .pyopenms_1 import *
ImportError: DLL load failed while importing pyopenms_1: 找不到指定的程序。

分析原因

https://github.com/OpenMS/OpenMS/issues/4291#issuecomment-1221604911

pyopenms这样的库自己有一个自带的pyqt版本,如果在导入这个库之前进行了其他图形化GUI库的导入,就会出错。所以有些人把import pyopenms放到import matplotlib.pyplot as plt前面就好了

对于部分代码工具(如Pycharm等),为了方便调试,会在debug时自动导入GUI库,就导致了问题的产生。

问题在于加载了同一个库的不同版本。因此,您只需确保不会意外地提供多个Qt版本。不幸的是,这在Windows上有点困难,因为您没有合适的包管理器,而且每个PythonWheel都绑定了自己的私有版本。

解决办法

在设置中找到 PyQt compatible 取消勾选 https://github.com/OpenMS/OpenMS/issues/4110#issuecomment-578613842

  • File | Settings | Build execution and deployment | Python debugger | PyQtCompatible = Unchecked

 

 

 

 
posted @ 2022-10-21 10:57  evtricks  阅读(5744)  评论(0编辑  收藏  举报