You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python 3.7环境下PyInstaller运行异常(缺失encodings模块)求助

Hey there, let's work through this PyInstaller issue you're hitting with Python 3.7.0b1 on Windows 10 64-bit. Pre-release Python versions plus older PyInstaller builds often cause these kinds of hiccups, so here's a step-by-step breakdown to fix it:

Core Issue Breakdown

Your problem stems from two main sources:

  • Python 3.7.0b1 is a pre-release version: PyInstaller 3.3.1 doesn't have full compatibility with its newer internal structures.
  • Missing system dependencies & unbundled modules: The api-ms-win-crt-*.dll warnings point to missing Windows runtime libraries, and the encodings module isn't being automatically packaged by PyInstaller.
Fix Steps

1. Upgrade PyInstaller to a Python 3.7-compatible version

PyInstaller 3.3.1 is too old to properly support Python 3.7. You'll need a newer build that includes fixes for this version:

  • First uninstall the old version:
    pip uninstall pyinstaller -y
    
  • Install the latest stable release (version 3.4+ adds Python 3.7 support; 4.x+ is recommended):
    pip install pyinstaller --upgrade
    
  • If stable still has issues, try the development build which often has pre-release compatibility fixes:
    pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
    

2. Force-include the encodings module

If upgrading doesn't resolve the missing encodings error, manually tell PyInstaller to bundle it:

  • Add the --hidden-import flag to your pack command:
    pyinstaller --hidden-import encodings your_test_script.py
    
  • Alternatively, create a .spec file (run pyinstaller your_test_script.py once to generate it), then add encodings to the hiddenimports list:
    # Example snippet from the .spec file
    a = Analysis(['your_test_script.py'],
                 pathex=['C:\\path\\to\\your\\script'],
                 binaries=[],
                 datas=[],
                 hiddenimports=['encodings'],  # Add this line
                 hookspath=[],
                 runtime_hooks=[],
                 excludes=[],
                 win_no_prefer_redirects=False,
                 win_private_assemblies=False,
                 cipher=None,
                 noarchive=False)
    
    Then re-pack using the spec file:
    pyinstaller your_test_script.spec
    

3. Resolve missing api-ms-win-crt-*.dll warnings

These DLLs are part of the Windows Universal CRT, which Python 3.7 depends on. Fix this by:

  • Installing the Visual C++ Redistributable for Visual Studio 2017 (this is the official way to get these libraries; make sure to grab the 64-bit version matching your system).
  • If you can't install the redistributable, manually copy the missing DLLs from your Python installation directory (C:\apps\python\python37) or C:\Windows\System32 into the folder where your packaged executable lives.

Since you're using a beta version of Python 3.7, you might run into other unforeseen compatibility issues. Consider upgrading to the latest stable Python 3.7 release (like 3.7.10) — pre-release builds are great for testing, but not ideal for production or tooling compatibility.

内容的提问来源于stack exchange,提问作者joe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:10:52