Python3.5.2 64位环境下PyInstaller打包失败求助
Hey there, let's work through this PyInstaller issue together—since you're on an older Python version (3.5.2 64-bit), there are specific checks we can run to get your main.py bundled successfully.
Here are the steps to debug and fix this:
Install a PyInstaller version compatible with Python 3.5.2
Newer PyInstaller versions dropped support for Python 3.5, so you need to install the last compatible release (version 3.6). Run this command in your terminal:pip install pyinstaller==3.6If you're using a virtual environment, make sure it's activated first before running this.
Capture and share full error output
You mentioned the command fails, but didn't include the specific error messages. PyInstaller almost always logs why it fails—look for red text or error lines in the console (like missing modules, permission denied, or path issues). Sharing these details will make it way easier to pinpoint the problem.Fix permission issues
Running PyInstaller fromC:\Program Files\Python35\scriptsmight trigger permission blocks, since this is a protected system directory. Try either:- Right-click your command prompt/terminal and select "Run as administrator" before executing the packaging commands, or
- Move your
main.pyfile to a non-system directory (likeD:\MyPythonProjects) and run PyInstaller from there instead.
Avoid problematic paths
Double-check that the path to yourmain.pydoesn't have spaces, Chinese characters, or special symbols (even though you used quotes, older PyInstaller versions can still struggle with this). Move your project to a simple path likeD:\Projects\main.pyif needed.Test with a minimal script
To rule out issues with yourmain.py's dependencies, create a tiny test script (e.g.,test.pywith justprint("Hello World!")) and run the same PyInstaller command on it. If this works, the problem is likely with a library in your original script that PyInstaller can't auto-detect. You'll need to use the--hidden-importflag to manually include missing modules, like:pyinstaller --onefile --hidden-import=your_missing_module main.py
内容的提问来源于stack exchange,提问作者OCG

