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

windonw cmd下的输出:

复制代码
(python3.9) PS D:\git\ImageAnalysisService\core\medical_bills> python
Python 3.9.19 (main, May  6 2024, 20:12:36) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import exceptiongroup
>>> import anyio
>>> import ssl
>>> import _ssl
>>> print(ssl)
<module 'ssl' from 'D:\\conda\\envs\\python3.9\\lib\\ssl.py'>
>>> print(_ssl)
<module '_ssl' from 'D:\\conda\\envs\\python3.9\\DLLs\\_ssl.pyd'>
>>>

pycharm下的输出:

复制代码
D:\git\ImageAnalysisService\venv\Scripts\python.exe D:\git\ImageAnalysisService\core\medical_bills\analysis_system.py 
Traceback (most recent call last):
  File "D:\git\ImageAnalysisService\core\medical_bills\analysis_system.py", line 10, in <module>
    import ssl
  File "D:\conda\envs\python3.9\lib\ssl.py", line 99, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed while importing _ssl: 找不到指定的模块。

环境相同,都是同一个虚拟环境的,怎么不同地方会有问题呢?

环境中分明是有这个包的,但是就是找不到,看这个_ssl包的路径和ssl包路径不同,猜想是可以copy一份到DLL路径中或者是lib路径中;

结合博客中https://blog.csdn.net/LeiChennb/article/details/134586416的说法:

因为缺少DLL,但是博客中是在conda上操作,我想,应该在conda env中操作,对虚拟环境进行操作;

如此操作:

"D:\conda\envs\python3.9\Library\bin\libcrypto-3-x64.dll"

"D:\conda\envs\python3.9\Library\bin\libssl-3-x64.dll"

复制到:

"D:\conda\envs\python3.9\DLLs"

果然就解决了问题;

相关推荐
Jazz_z12 小时前
如何用Python将彩色PDF一键转为黑白(灰度)
java·python·pdf
SEO_juper12 小时前
2026年Schema自动注入实战:用Python批量给1000个页面加上JSON-LD,AI引用率实测提升38%
人工智能·python·json·seo·独立站
zzzll111113 小时前
HashMap、HashTable、ConcurrentHashMap 详细区别与深度解析
开发语言·python
程序员AI工坊13 小时前
Agent 开发:ReAct 循环与工具调用实战——从单次调用到自主 Agent
人工智能·后端·python·langchain·agent·react
️学习的小王13 小时前
基于UDP实现简易聊天室(基础版)——Python实现
网络·python·udp
W_3260013 小时前
Python 组合数据类型——序列(列表 & 元组)
开发语言·python
二进制杯莫停14 小时前
A和B环境的python版本相同,B环境无法安装pip依赖,离线安装
开发语言·python·pip
威联通安全存储14 小时前
TS-h1677AXU-RP 在汽车冲压车间高速冲压线检测网中的部署
python·汽车
RSTJ_162515 小时前
PYTHON+AI LLM DAY ONE HUNDRED AND TWENTY-NINE
人工智能·python
夏天测15 小时前
Python 网络编程从 TCP 三次握手到 Socket 搭建极简 AI 推理服务端(零基础可跑通完整代码)
python·socket·网络通信·tcp 网络编程·零基础网络编程