Search code examples
pythonpyinstaller

Pyinstaller exe won't work outside the dist folder


I used Pyinstaller to create an exe and the file works well when running inside the dist folder. However when I make a copy of it and run it in a different directory, it doesn't start up. I need to run the exe on another PC... should I make a zip file of the entire folder and distribute the zip? If anyone could help, it'd be appreciated!

I'm using:

  • Python 3.8.8
  • Pyinstaller 4.4
  • Windows 10

Solution

  • The dist folder contains all of your programs dependencies, yes. You'll have to distribute everything there to any computer that you expect to run your application.

    Alternatively, you can use --one-file as was mentioned in the comments. Use caution with that though, it'll produce a single file that's actually a self-extracting archive that puts your dist directory in a temporary location, runs your app, then cleans itself up. That can be a large amount of start-up and disk churn overhead for a simple script.