import _ssl # if we can‘t import it, let the error propagate

运行gym_derk时,导入ssl出错。

完整报错如下:

import _ssl # if we can’t import it, let the error propagate

ImportError: DLL load failed while importing _ssl: 找不到指定的模块。

尝试了很多解决方法,最后是通过找到以下两个文件,复制到运行环境的DLLs的目录下解决的。

libcrypto-1_1-x64.dll
libssl-1_1-x64.dll

以我自己的为例,我的运行环境名为pytorch

上述两个dll文件一般会存在运行环境的bin文件夹中,比如在我这里的路径是这个:

D:\Anaconda3\envs\pytorch\bin

然后粘到对应的DLLs目录下问题解决,在我这里是这个:

D:\Anaconda3\envs\pytorch\DLLs

在粘贴之前要先检测下DLLs文件夹下有没有_ssl.pyd文件,因为把这两个dll文件粘贴过去的原因就是_ssl.pyd运行需要它们,所以要把它们粘到与_ssl.pyd相同的文件目录下。

我第一次尝试这个方法的时候是从GitHub上看到的,但他只让我粘libssl-1_1.dll和libcrypto-1_1.dll,但粘过去之后还是报错,后来看到应该用后面有x64的。

GitHub回答链接是这个:

Getting error while importing ssl ” import _ssl # if we can’t import it, let the error propagate ImportError: DLL load failed while importing _ssl: The specified module could not be found.” · Issue #83525 · python/cpython · GitHub

还有其他解决方法可以参考下这个博客,写的很全:

(20条消息) import _ssl ImportError: DLL load failed_学习记录册的博客-CSDN博客_import _ssl

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(1)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年3月28日 下午11:43
下一篇 2023年3月29日 上午7:38

相关推荐