Py to EXE using Pyinstaller

i’m trying to make a exe file from my python file. I installed pyinstaller using pip and run the command it executed properly and i got a dist folder as well. But instead of a exe file it had a txt file. Please someone guide i have to submit the school project but my pc is really low end (4GB RAM).

Hi @prakhardoneria and welcome to the community!

When you run PyInstaller, it provides output in the terminal indicating the process it’s performing and any potential issues. Could you check what was in the output and tell us here?

1 Like

Thanks for reply, the issue is i can’t copy the text from terminal. It shows successfully made exe but exe doens’t comes. If you want I can share repl link.

Please highlight the text you wish to copy, right-click and press copy.

Please link your Repl.

I always had issues with Pyinstaller, but not on a Repl. You might try running pyinstaller main.py --onefile and that usually does it for me. You can also type --noconsole if you don’t want a console and you want it to run in the background.

You might have to do a crazy thing where you import a random module inside of the EXE, which gets really weird. It’s a very finicky tool, but with your Repl link I can take a closer look.

2 Likes

This is my Repl link https://replit.com/@prakhardoneria/BMI-Calculator

Please fork it and run Pyinstaller command line in shell (maybe I have uninstalled Pyinstaller because of storage so which double check it). You will get dist folder in directory but the main file inside it will be a text other than a exe file for windows. Even I tried downloading it, size was about 11MB when i opened it Notepad opened :skull:

1 Like

That’s odd. I tried changing the file extension to EXE and running it on my PC, but it didn’t work (said it was invalid and couldn’t run).

I know this goes against the whole purpose of Replit, but can you try installing Python and Pyinstaller on your computer and going that way?

Oh yeah, maybe that’s why. Replit containers are Linux-based, while Pyinstaller is made to build EXEs (for Windows).

3 Likes

Ok thanks for your time :smiling_face:

I forked your project and he did create a main.exe file inside the dist folder.
The thing is, as you can see in the Platform line: Platform: Linux-6.2.0-1019-gcp-x86_64-with ), this means that PyInstaller will generate a Linux executable, not a Windows .exe file. The generated file will be a Linux executable and won’t have an .exe extension.

In this case, the most practical solution is to use a native Windows environment to create your Windows executable.

1 Like

Is there not a flag you can add to switch OSes/file type? :thinking:

1 Like

Not that I know of, cross-compiling is something really complex which I don’tk think replit enables this. (But if it do, I will be dumbfold)

1 Like