You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Linux Mint 20下PyInstaller生成的可执行文件无法运行求助

Fixing PyInstaller Executable Not Running on Linux Mint 20 (Python 3.8)

Hey there, I’ve dealt with similar PyInstaller quirks on Mint before, so let’s break down how to get your executable working properly:

1. First, Check Executable Permissions

Double-click failures often start with missing execution rights. Here’s how to fix it:

  • Graphical way: Right-click your generated executable → Go to the Permissions tab → Check the box labeled "Allow executing file as program".
  • Terminal way: Run this command in the directory where your executable lives:
    chmod +x ./your_executable_name
    

After setting permissions, try double-clicking again.

2. Run the Executable in Terminal to See Error Messages

The biggest issue with double-clicking is you can’t see why it’s failing. Open a terminal, navigate to the executable’s folder, and run it directly:

./your_executable_name

This will print specific error logs—like missing system libraries, missing Python modules, or path issues. For example, if it complains about a missing libgtk-3.so file, you can install the required package with sudo apt install libgtk-3-0.

3. Adjust PyInstaller Packing Parameters

Depending on your script type, you might need extra flags to pack correctly:

  • If your script is a GUI app: If you’re seeing a terminal window flash and disappear (or nothing at all), use the --windowed flag to create a GUI-only executable:
    python3 -m PyInstaller --windowed filename.py
    
  • If your script uses dynamically imported modules: PyInstaller sometimes misses modules loaded at runtime. Use --hidden-import to explicitly include them:
    python3 -m PyInstaller --hidden-import your_missing_module filename.py
    
  • For more verbose packing: Add -v to see what PyInstaller is doing during the build, which can help spot missing components:
    python3 -m PyInstaller -v filename.py
    

4. Update PyInstaller and Check Your Python Environment

Outdated PyInstaller versions can cause compatibility issues with Python 3.8. Update it first:

python3 -m pip install --upgrade pyinstaller

Also, if you’re using a virtual environment, make sure it’s activated when you run the PyInstaller command—this ensures all your script’s dependencies are included in the build:

source your_virtual_env/bin/activate
python3 -m PyInstaller filename.py

5. Quick Note on the "pyinstaller: command not found" Error

The reason you had to use python3 -m PyInstaller instead of just pyinstaller is that the PyInstaller executable isn’t in your system’s PATH. After updating PyInstaller, try running pyinstaller --version—it might work now, but using the module-style command is totally fine too.

Start with step 2 first—seeing the actual error will point you straight to the fix 90% of the time.

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

火山引擎 最新活动