#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 检查 SSL DLL 文件是否存在 """ import os import sys def check_ssl_dlls(): """检查 SSL 相关的 DLL 文件""" print("=" * 60) print("检查 SSL DLL 文件") print("=" * 60) # 获取 Python 安装目录 python_dir = os.path.dirname(sys.executable) dll_dir = os.path.join(python_dir, 'DLLs') print(f"\nPython 目录: {python_dir}") print(f"DLLs 目录: {dll_dir}") print(f"DLLs 目录存在: {os.path.exists(dll_dir)}") # 需要检查的 DLL 列表 dll_names = [ 'libcrypto-1_1-x64.dll', 'libssl-1_1-x64.dll', 'libcrypto-3-x64.dll', 'libssl-3-x64.dll', '_ssl.pyd', '_hashlib.pyd', ] print("\n检查 DLL 文件:") print("-" * 60) found_dlls = [] for dll_name in dll_names: dll_path = os.path.join(dll_dir, dll_name) exists = os.path.exists(dll_path) status = "✓ 找到" if exists else "✗ 未找到" print(f"{status:10} {dll_name}") if exists: found_dlls.append((dll_path, dll_name)) file_size = os.path.getsize(dll_path) print(f" 路径: {dll_path}") print(f" 大小: {file_size:,} 字节") print("\n" + "=" * 60) print(f"总计找到 {len(found_dlls)} 个文件") print("=" * 60) # 尝试导入 ssl 模块 print("\n测试导入 SSL 模块:") print("-" * 60) try: import ssl print("✓ ssl 模块导入成功") print(f" OpenSSL 版本: {ssl.OPENSSL_VERSION}") except ImportError as e: print(f"✗ ssl 模块导入失败: {e}") try: import _ssl print("✓ _ssl 模块导入成功") except ImportError as e: print(f"✗ _ssl 模块导入失败: {e}") # 检查 conda 环境 print("\n" + "=" * 60) print("Conda 环境信息:") print("-" * 60) conda_prefix = os.environ.get('CONDA_PREFIX') if conda_prefix: print(f"Conda 环境: {conda_prefix}") conda_dll_dir = os.path.join(conda_prefix, 'Library', 'bin') print(f"Conda DLLs 目录: {conda_dll_dir}") print(f"Conda DLLs 目录存在: {os.path.exists(conda_dll_dir)}") if os.path.exists(conda_dll_dir): print("\n检查 Conda DLL 文件:") for dll_name in dll_names: dll_path = os.path.join(conda_dll_dir, dll_name) exists = os.path.exists(dll_path) status = "✓ 找到" if exists else "✗ 未找到" print(f"{status:10} {dll_name}") if exists: print(f" 路径: {dll_path}") else: print("未在 Conda 环境中运行") return found_dlls if __name__ == "__main__": check_ssl_dlls()