How to convert .py to .exe? Step by step guide.

Eshleron on January 24, 2019

Auto PY to EXE The only tool that we are gonna be using is Auto PY to EXE! Auto PY to EXE is an amazing application for making .exe f... [Read Full]
markdown guide
 
 

Hey buddy, thanks for creating this. I have a problem though: in my python script I call several files that are in the current working directory, based on relative paths to simplify it. Once it's compiled to the exe, it seems that the program goes to the root folder of the computer as an absolute route. This kind of defeats the object since my program has to run in a folder with other files being added and removed.

What can I do to force the .exe to work on relative paths exactly the same way I have my script?

thanks

 

Hi!
1.What I usually do is get an absolute path so the script\scripts always know where they are

import os
dir = os.path.dirname(__file__)
abs_path = os.path.join(dir, DB_DOCS_NAME)
variable = open(abs_path)

2.If the main script is looking in the wrong place for other scripts then probably your imports are not correct.
Try to use this resource
realpython.com/absolute-vs-relativ...

Hope that I helped in some way

 
 

This looks great! I do want to give a quick shout-out to Nim

If you're looking to build performant executables and Python is what you're really comfortable, I think you'll find Nim's syntax pleasingly similar; and the performance improvements are real 😀

 

hey when I add the dll files using add files drop down and create the exe , when i try to open the exe it says "failed to compile the exe file_name" , can you please help out with this it urgent as well Thank you so much in advance

 

Hi! Can you please send some screenshots?

 

I can't install it :
Command ""c:\program files (x86)\python37-32\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\NATHAN~1\AppData\Local\Temp\pip-install-d_n5yima\future\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\NATHAN~1\AppData\Local\Temp\pip-record-oaye_ir1\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\NATHAN~1\AppData\Local\Temp\pip-install-d_n5yima\future\
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

I've try to upgrade pip but i can't uninstall my last version

 

It's not pip version problem I think. I would reinstall pip or python(if nothing helps) if googling doesn't help. Couple months passed since you asked, probably you already have a solution.

 

It's not good to do this. The performance will stay same (even decreased) and it will lose the cross-platform ability.

 

I think a common use case is sharing a Python program with someone who might not have the interpreter installed.

 

I am facing the below issue while converting py to exe. It if failing at Analysis due to log formatting syntax.

 
 

I am facing the below issue while converting py to exe. It if failing at Analysis due to log formatting syntax.

[thepracticaldev.s3.amazonaws.com/i...]

 

Hi!
1.If you still have the problem I would look and the string itself with
log.error(f""). Dont think that you can do what I think you are trying to do.

2.If second error is present after you delt with the first one, then simple recomendation is to reinstall pyinstaller. I had multiple problems with converting and they mostly got solved by restarting converting process.

code of conduct - report abuse