首页 > 其他分享 >anaconda环境 使用PyInstaller打包,运行exe文件出现导入_ssl错误

anaconda环境 使用PyInstaller打包,运行exe文件出现导入_ssl错误

时间:2024-06-07 10:35:17浏览次数:22  
标签:INFO Files exe PyInstaller Users Anaconda3 CloudImage anaconda ASUS

使用PyInstaller打包后运行exe文件出现错误NameError: name 'ssl' is not defined
观察PyInstaller打包程序输出,发现找不到DLL文件的警报,查看对应环境下的DLLs文件夹发现导入ssl的DLL文件缺失。
查阅资料发现由于anaconda环境DLL文件错误存放在lib文件夹下面,致使PyInstaller打包程序找不到DLL文件,引发问题。
如果你是通过系统路径使用的PyInstaller,可以使用

where pyinstaller

命令找出所使用的pyinstaller的位置。
在其对应的文件目录下,根据你的警告信息将缺失的DLL文件从
C:\Users\<用户名>\Anaconda3\Library\bin复制到C:\Users\<用户名>\Anaconda3\DLLs 中。
如果使用虚拟环境则将缺失的DLL文件从
C:\Users\<用户名>\Anaconda3\envs\<conda虚拟环境名>\Library\bin复制到C:\Users\<用户名>\Anaconda3\envs\<conda虚拟环境名>\DLLs中。
如果觉得繁琐可将所有.dll后缀的文件复制到目标文件夹。
重新打包,问题解决。
希望这篇文章可以帮助到你,附笔者pyinstaller打包输出:

C:\Users\ASUS\Anaconda3\envs\CloudImage\Scripts\pyinstaller.exe -F -w -i cloudImage.ico upload.py
985 INFO: PyInstaller: 5.13.2
985 INFO: Python: 3.10.14 (conda)
1001 INFO: Platform: Windows-10-10.0.22000-SP0
1001 INFO: wrote D:\zhidian_Internet\CloudImage\upload.spec
1017 INFO: Extending PYTHONPATH with paths
['D:\\zhidian_Internet\\CloudImage']
1604 INFO: checking Analysis
1604 INFO: Building Analysis because Analysis-00.toc is non existent
1604 INFO: Initializing module dependency graph...
1614 INFO: Caching module graph hooks...
1635 INFO: Analyzing base_library.zip ...
5032 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks'...
7285 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks'...
8127 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks'...
8828 INFO: Caching module dependency graph...
8999 INFO: running Analysis Analysis-00.toc
9019 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\Users\ASUS\Anaconda3\envs\CloudImage\python.exe
9320 INFO: Analyzing D:\zhidian_Internet\CloudImage\upload.py
9505 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
10599 INFO: Loading module hook 'hook-cryptography.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
13723 INFO: Loading module hook 'hook-certifi.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
13955 INFO: Loading module hook 'hook-selenium.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
14421 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks'...
C:\Users\ASUS\Anaconda3\envs\CloudImage\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py:208: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if setting is None or setting is '':
14567 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks'...
14567 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks'...
15254 INFO: Processing module hooks...
15284 INFO: Looking for ctypes DLLs
15291 INFO: Analyzing run-time hooks ...
15291 INFO: Including run-time hook 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
15291 INFO: Including run-time hook 'C:\\Users\\ASUS\\Anaconda3\\envs\\CloudImage\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
15307 INFO: Looking for dynamic libraries
1695 INFO: Extra DLL search directories (AddDllDirectory): []
1695 INFO: Extra DLL search directories (PATH): ['D:\\Program Files\\CUDA\\bin', 'D:\\Program Files\\CUDA\\libnvvp', 'C:\\Program Files\\Microsoft\\jdk-11.0.12.7-hotspot\\bin', 'C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath', 'C:\\Program Files (x86)\\VMware\\VMware Workstation\\bin\\', 'C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\iCLS\\', 'C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\iCLS\\', 'C:\\Windows\\system32', 'C:\\Windows', 'C:\\Users\\ASUS\\Anaconda3\\Scripts', 'C:\\Users\\ASUS\\Anaconda3', 'C:\\Windows\\System32\\Wbem', 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\Windows\\System32\\OpenSSH\\', 'C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL', 'C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL', 'C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT', 'C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT', 'C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common', 'C:\\Program Files\\Intel\\WiFi\\bin\\', 'C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\', 'C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR', 'C:\\WINDOWS\\system32', 'C:\\WINDOWS', 'C:\\WINDOWS\\System32\\Wbem', 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\', 'C:\\WINDOWS\\System32\\OpenSSH\\', 'C:\\Program Files\\Java\\jdk1.8.0_221\\bin', 'G:\\System64\\graphviz\\bin', 'C:\\Program Files\\dotnet\\', 'C:\\Program Files (x86)\\dotnet\\', 'C:\\Dev-Cpp\\MinGW64\\bin', 'E:\\MongoDB\\Server\\4.2.5\\bin', 'C:\\Program Files\\Git\\cmd', 'D:\\Program Files\\LLVM\\bin', 'D:\\Program Files\\clang+llvm-14.0.0-amd64-pc-solaris2.11\\bin', 'C:\\Program Files\\NVIDIA Corporation\\Nsight Compute 2022.1.1\\', 'C:\\Program Files\\TortoiseSVN\\bin', 'D:\\Program Files (x86)\\node.js\\', 'D:\\Program Files\\php-8.0.30-nts-Win32-vs16-x64', 'C:\\Users\\ASUS\\.m2\\wrapper\\dists\\apache-maven-3.8.4-bin\\52ccbt68d252mdldqsfsn03jlf\\apache-maven-3.8.4\\bin', 'C:\\Users\\ASUS\\AppData\\Local\\Programs\\Python\\Python37\\Scripts\\', 'C:\\Users\\ASUS\\AppData\\Local\\Programs\\Python\\Python37\\', 'C:\\Users\\ASUS\\AppData\\Local\\Microsoft\\WindowsApps', 'C:\\Users\\ASUS\\AppData\\Local\\Programs\\Microsoft VS Code\\bin', 'C:\\Users\\ASUS\\.dotnet\\tools', 'F:\\Program Files (x86)\\IDEA\\IntelliJ IDEA 2021.3.2\\bin', 'E:\\Program Files (x86)\\py\\PyCharm 2022.1\\bin', 'D:\\Program Files (x86)\\cpolar\\', 'C:\\Users\\ASUS\\AppData\\Roaming\\npm', 'D:\\Program Files (x86)\\PhpStorm 2022.2.5\\bin']
2028 WARNING: lib not found: libcrypto-3-x64.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\DLLs\_hashlib.pyd2044 WARNING: lib not found: liblzma.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\DLLs\_lzma.pyd
2060 WARNING: lib not found: LIBBZ2.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\DLLs\_bz2.pyd
2096 WARNING: lib not found: libssl-3-x64.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\DLLs\_ssl.pyd
2117 WARNING: lib not found: libcrypto-3-x64.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\DLLs\_ssl.pyd
2139 WARNING: lib not found: libssl-3-x64.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\lib\site-packages\cryptography\hazmat\bindings\_rust.cp310-win_amd64.pyd
2155 WARNING: lib not found: libcrypto-3-x64.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\lib\site-packages\cryptography\hazmat\bindings\_rust.cp310-win_amd64.pyd
2206 WARNING: lib not found: ffi.dll dependency of C:\Users\ASUS\Anaconda3\envs\CloudImage\DLLs\_ctypes.pyd
17763 INFO: Looking for eggs
17768 INFO: Using Python library C:\Users\ASUS\Anaconda3\envs\CloudImage\python310.dll
17768 INFO: Found binding redirects:
[]
17773 INFO: Warnings written to D:\zhidian_Internet\CloudImage\build\upload\warn-upload.txt
17832 INFO: Graph cross-reference written to D:\zhidian_Internet\CloudImage\build\upload\xref-upload.html
17868 INFO: checking PYZ
17868 INFO: Building PYZ because PYZ-00.toc is non existent
17868 INFO: Building PYZ (ZlibArchive) D:\zhidian_Internet\CloudImage\build\upload\PYZ-00.pyz
18398 INFO: Building PYZ (ZlibArchive) D:\zhidian_Internet\CloudImage\build\upload\PYZ-00.pyz completed successfully.
18414 INFO: checking PKG
18414 INFO: Building PKG because PKG-00.toc is non existent
18414 INFO: Building PKG (CArchive) upload.pkg
20229 INFO: Building PKG (CArchive) upload.pkg completed successfully.
20229 INFO: Bootloader C:\Users\ASUS\Anaconda3\envs\CloudImage\lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\runw.exe
20229 INFO: checking EXE
20229 INFO: Building EXE because EXE-00.toc is non existent
20229 INFO: Building EXE from EXE-00.toc
20229 INFO: Copying bootloader EXE to D:\zhidian_Internet\CloudImage\dist\upload.exe.notanexecutable
20280 INFO: Copying icon to EXE
20280 INFO: Copying icons from ['D:\\zhidian_Internet\\CloudImage\\cloudImage.ico']
20308 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
20308 INFO: Writing RT_ICON 1 resource with 4264 bytes
20318 INFO: Copying 0 resources to EXE
20318 INFO: Embedding manifest in EXE
20318 INFO: Updating manifest in D:\zhidian_Internet\CloudImage\dist\upload.exe.notanexecutable
20349 INFO: Updating resource type 24 name 1 language 0
20355 INFO: Appending PKG archive to EXE
20365 INFO: Fixing EXE headers
22274 INFO: Building EXE from EXE-00.toc completed successfully.

标签:INFO,Files,exe,PyInstaller,Users,Anaconda3,CloudImage,anaconda,ASUS
From: https://www.cnblogs.com/cmd-gd/p/18236684

相关文章

  • C# 调用外部exe的三种方式
    C# 调用外部exe的三种方式调用外部exe是常用的功能,本文主要介绍了C# 调用外部exe的三种方式,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习吧 方式一:直接调用Process类来实现:usingSystem.Diagnostics;Processp=Process.Start("program.e......
  • 如何创建一个线程池,为什么不推荐使用Executors去创建呢?
    我们在学线程的时候了解了几种创建线程的方式,比如继承Thread类,实现Runnable接口、Callable接口等,那对于线程池的使用,也需要去创建它,在这里我们提供2种构造线程池的方法:方法一:通过ThreadPoolExecutor构造函数来创建(首选)  这是JDK中最核心的线程池工具类,在JDK1.8中,它提供了丰......
  • Nativefier : 将网址打包成exe桌面程序
    1、需求场景    在日常开发中,需要针对一些网页在一体机上使用,同时在浏览器上也可以使用,这里推荐大家用nativefier,对网址进行打包。以下是nativefier安装命令:npminstallnativefier-g2、使用方法--arch系统--icon小图标文件,必须是256*256默认从网页的关键......
  • python如何编译成exe文件
    python如何编译成exe文件?具体步骤如下:1、使用pycharm安装pyinstaller。2、找到pyinstaller的安装目录。C:\Users\lounious\PycharmProjects\untitled\venv\Scripts\pyinstaller-script.py注意在该目录的母目录下一般有我们的程序文件C:\Users\lounious\PycharmProject......
  • Python并发 :ThreadPoolExecutor
    concurrent.futures是Python中执行异步编程的重要工具,它提供了以下两个类: 1.ThreadPoolExecutorfromconcurrent.futuresimportThreadPoolExecutordeftest(num):print("Threads"num)#新建ThreadPoolExecutor对象并指定最大的线程数量withThreadPoolExecutor(......
  • python之pyexecjs
    pyexecjs是一个用Python来执行JavaScript代码的工具库,该库支持多种JavaScript运行时环境,如Node.js、PhantomJS、SlimerJS等,允许开发者在Python中无缝地调用和执行JavaScript代码。 [安装]pipinstallpyexecjs [使用]1.eval方式importexecjsprint(execjs.eval('"abc......
  • 【VS Code使用】仅当从 VS 开发人员命令提示符处运行 VS Code 时,cl.exe 生成和调试才
    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档文章目录一、前言......
  • 记录 anaconda安装labelimg
    前提:已经安装anaconda1、下载labelimg:labelImg:LabelImgisnowpartoftheLabelStudiocommunity.ThepopularimageannotationtoolcreatedbyTzutalinisnolongeractivelybeingdeveloped,butyoucancheckoutLabelStudio,theopensourcedatalabelingtoo......
  • AutoCAD不响应,等待资源监视器中的svchost.exe进程
    问题:启动AutoCAD时,没有软件响应。如果打开“任务管理器—性能—打开资源监视器”,则显示acad.exe进程等待svchost.exe继续。解决方案:请尝试以下步骤作为解决方法:重命名AdDownloaderCore.dll文件,该文件位于以下目录:C:\ProgramFiles\Autodesk\AutoCAD201x。尝试运行Au......
  • allure的suites(测试套)中未显示返回值参数,显示No information about test execution is
    转自大佬:https://blog.csdn.net/sbdxmnz/article/details/137016423 ExecutionNoinformationabouttestexecutionisavailable.  解决方法:添加代码,因为pytest输出文本形式测试报告时未存储响应内容#将接口响应的文本内容附加到Allure报告中allure.attach(接口响......