DEV Community

Cover image for How to convert .py to .exe? Step by step guide.

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 fil...
Collapse
 
joehobot profile image
Joe Hobot


mv somefile.py somefile.exe

😛

Collapse
 
eshleron profile image
Eshleron

😛

Collapse
 
r4nta profile image
r4nta

Great post!

I load variables from a config.py file. How would I enable users to modify this file OUTSIDE the .exe?

Collapse
 
eshleron profile image
Eshleron

Hi!
Don't pack it into .exe file. Leave it outside .exe. It should work that way.

Collapse
 
r4nta profile image
r4nta

Thanks for your quick response!

How can I leave the config.py file outside? I feel that PyInstaller loads the config.py file, compiles it into the exe and then has this fixed state in the program. I need to be able to modify the config file, after compiling.

How do I instruct PyInstaller to leave the config.py file separate?

Thread Thread
 
eshleron profile image
Eshleron

You are right about fixed state. What PyInstaller remembers is the name of the file. So if you paste the same file with different content(some .txt maybe) it will work with it just fine because it thinks it is the same file.

Thread Thread
 
r4nta profile image
r4nta

That would be amazing and a super easy solve. Problem: I cannot find the config.py in the folder that was created by PyInstaller. Actually I can't find any of the modules I import. Are they merged into the .exe file?

Thread Thread
 
eshleron profile image
Eshleron

You should add files manually sometimes. Try copying config there. It should work.

Thread Thread
 
r4nta profile image
r4nta

It does not work. When I manually add the config.py, the file is added - yes. But when I change variables in the file, nothing changes in the program. The .exe does not load data from the config.py

Thread Thread
 
eshleron profile image
Eshleron

Make sure you added the fie to Auto PY to EXE additional files menu for it to be compilated with .exe.

Thread Thread
 
r4nta profile image
r4nta

I changed my config file to .json and now it works. Even with adding the file manually, it does NOT work when the file is .py (the file was in the folder, but changing settings did not reflect in the script).

Thread Thread
 
qwerty_plm profile image
SwethaVSarma

Can you please suggest on how to do this? I have converted the python codes to exe using pyinstaller. I kept the input python file wthout converting to .exe so that the main exe can read from it. But when i change the values in the input python file I have to again use pyinstaller and do the convertion of main python file.

Collapse
 
elputojay profile image
𝕛𝕒𝕪 🇪🇸

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

Collapse
 
eshleron profile image
Eshleron • Edited

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)
Enter fullscreen mode Exit fullscreen mode

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

Collapse
 
prohashim profile image
ProHashim • Edited

Hi there! Thanks a lot for this beautiful article.
But when I try to run auto-py-to-exe I am getting this error:

Traceback (most recent call last):
File "C:\Users\Muhammad Hashim\AppData\Local\Programs\Python\Python38\Scripts\auto-py-to-exe-script.py", line 6, in
from pkg_resources import load_entry_point
File "C:\Users\Muhammad Hashim\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources_init.py", line 3251, in
def _initialize_master_working_set():
File "C:\Users\Muhammad Hashim\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources__init
.py", line 3234, in _call_aside
f(*args, **kwargs)
File "C:\Users\Muhammad Hashim\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources__init
.py", line 3263, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "C:\Users\Muhammad Hashim\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources__init
.py", line 583, in _build_master
ws.require(
requires)
File "C:\Users\Muhammad Hashim\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources__init
.py", line 900, in require
needed = self.resolve(parse_requirements(requirements))
File "C:\Users\Muhammad Hashim\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources__init
_.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Eel==0.11.0' distribution was not found and is required by auto-py-to-exe

Collapse
 
eshleron profile image
Eshleron • Edited

Hi!
It says you need Eel 0.11.0. Try to install/reinstall Eel and launch auto-py-to-exe again.

Collapse
 
prohashim profile image
ProHashim

Thanks a lot !!!

Collapse
 
calebwin profile image
Caleb Winston

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 😀

Collapse
 
bauripalash profile image
Palash Bauri 👻

GUI Wrapper for PyInstaller! Gonna try

Collapse
 
rjkitto profile image
Rick Kitto

I love the idea of the program - thanks!
Everything seemed to go great - testing with just one file - moved it to my Windows 10 PC, and got the error message shown in the screen grab.
I hope this is fixable and that there's something simple I didn't do!

The image didn't seem to want to load. Here's what it said ...

"The program or feature cannot start due to incompatibnility
with 64-bit versions of Windows. Please contact the software vendor
to ask if a 64-bit Windows compatible version is available."

Collapse
 
eshleron profile image
Eshleron

Hi!
Probably you used Python x32 or some library that is x32. Check for that, then recompile.

Collapse
 
rjkitto profile image
Rick Kitto

Excellent - thanks for the suggestion - I'll get to work!
cheers, Rick

Collapse
 
qfactorin profile image
qFactorin

Unable to create exe from my .py file... could you help me out, I am relatively new to python or any other programming language for that matter.

Collapse
 
eshleron profile image
Eshleron

Hi!
Please provide screenshots of errors or some code so I can help.

Collapse
 
qfactorin profile image
qFactorin

Hi, thank you for the quick response. I have attached the screenshots, attaching them again....

Thread Thread
 
qfactorin profile image
qFactorin

pasting the output for your reference:

Running auto-py-to-exe v2.7.11
Building directory: C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui
Provided command: pyinstaller --noconfirm --onefile --console "C:/Users/Srini/AppData/Local/qFactor/.spyproject/qFactor_finalVersion-working-beforemoving.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onefile --console C:/Users/Srini/AppData/Local/qFactor/.spyproject/qFactor_finalVersion-working-beforemoving.py --distpath C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\application --workpath C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\build --specpath C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui

22730 INFO: PyInstaller: 4.1
22735 INFO: Python: 3.7.9
22739 INFO: Platform: Windows-10-10.0.18362-SP0
22749 INFO: wrote C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\qFactor_finalVersion-working-beforemoving.spec
22761 INFO: UPX is not available.
22769 INFO: Extending PYTHONPATH with paths
['C:\Users\Srini\AppData\Local\qFactor\.spyproject',
'C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui']
22815 INFO: checking Analysis
22820 INFO: Building Analysis because Analysis-00.toc is non existent
22825 INFO: Initializing module dependency graph...
22838 INFO: Caching module graph hooks...
22877 INFO: Analyzing base_library.zip ...
26058 INFO: Processing pre-find module path hook distutils from 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_find_module_path\hook-distutils.py'.
26063 INFO: distutils: retargeting to non-venv dir 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib'
27755 INFO: Caching module dependency graph...
27864 INFO: running Analysis Analysis-00.toc
27903 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Users\Srini\AppData\Local\Programs\Python\Python37\python.exe
28052 INFO: Analyzing C:\Users\Srini\AppData\Local\qFactor.spyproject\qFactor_finalVersion-working-beforemoving.py
28558 INFO: Processing pre-safe import module hook six.moves from 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-six.moves.py'.
30204 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-urllib3.packages.six.moves.py'.
An error occurred while packaging
Traceback (most recent call last):
File "C:\Users\Srini\Desktop\auto-py-to-exe-master\auto_py_to_exe\packaging.py", line 131, in package
run_pyinstaller()
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller_main.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller__main
.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build
exec(code, spec_namespace)
File "C:\Users\Srini\AppData\Local\Temp\tmpp_j94zui\qFactor_finalVersion-working-beforemoving.spec", line 17, in
noarchive=False)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 242, in __init
_
self.postinit()
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in postinit
self.assemble()
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\building\build_main.py", line 413, in assemble
priority_scripts.append(self.graph.run_script(script))
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 304, in run_script
pathname)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1424, in run_script
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1497, in import_hook
source_package, target_module_partname, level)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1654, in _find_head_package
target_module_headname, target_package_name, source_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1498, in import_hook
target_module = self._load_tail(target_package, target_module_partname)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1717, in _load_tail
submodule = self._safe_import_module(head, mname, submodule)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1497, in import_hook
source_package, target_module_partname, level)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1654, in _find_head_package
target_module_headname, target_package_name, source_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1497, in import_hook
source_package, target_module_partname, level)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1654, in _find_head_package
target_module_headname, target_package_name, source_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2523, in _safe_import_hook
edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1514, in import_hook
target_module, target_attr_names):
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1808, in _import_importable_package_submodules
attr_name, submodule_name, package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 442, in _safe_import_module
module_basename, module_name, parent_package)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2066, in _safe_import_module
module = self._load_module(module_name, pathname, loader)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2174, in _load_module
self._scan_code(m, co, co_ast)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2658, in _scan_code
self._process_imports(module)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2857, in _process_imports
target_module = self._safe_import_hook(*import_info, **kwargs)[0]
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2313, in _safe_import_hook
target_attr_names=None, level=level, edge_attr=edge_attr)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1498, in import_hook
target_module = self._load_tail(target_package, target_module_partname)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1717, in _load_tail
submodule = self._safe_import_module(head, mname, submodule)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\depend\analysis.py", line 431, in _safe_import_module
hook_module.pre_safe_import_module(hook_api)
File "C:\Users\Srini\AppData\Local\Programs\Python\Python37\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-urllib3.packages.six.moves.py", line 33, in pre_safe_import_module
raise SystemExit("pre-safe-import-module hook failed, needs fixing.")
SystemExit: pre-safe-import-module hook failed, needs fixing.

Project output will not be moved to output folder
Complete.

Thread Thread
 
eshleron profile image
Eshleron

Thanks.
I have not encountered this one myself, but here is what I found

readthedocs.org/projects/pyinstall...

Search for "pre_safe_import_module". There is a description of the method that might help you.
If that doesn't help I would personally look for libs that may be broken or have a potential of being incorrectly imported.

Thread Thread
 
qfactorin profile image
qFactorin

Hi Eshleron, thank you for taking time and looking in to it. I managed to resolve the issue.
I was unsure of the conflict so have installed python from scratch on a new virtual machine and tried creating exe without installing any packages.

  1. Installed packages that were only part of error logs.
  2. finally found out that reason for the failure was related to hidden import "babel.numbers".
  3. included that as parameter in hidden imports in auto-py-to-exe, and boom everything worked........
Thread Thread
 
eshleron profile image
Eshleron

Glad you got it fixed!

Thread Thread
 
eshleron profile image
Eshleron • Edited

So now I have encountered "SystemExit: pre-safe-import-module hook failed, needs fixing." error myself. I've tried "babel.numbers" solution, didn't help. What helped me solve it was a combination of google search and intuition.

My error was something like this: "PyInstaller\hooks\pre_safe_import_module\hook-urllib3.packages.six.moves.py", line 33, in pre_safe_import_module"

  1. First, as the internet suggested, I uninstalled "usual" Pyinstaller and installed Pyinstaller dev with:
    pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip.
    That took care of this problem.

  2. But then the second problem emerged: "ImportError: Module 'pywintypes' isn't in frozen sys.path". That was solved by excluding pywin32 from imports in Auto-py-to-exe (Pyinstaller).

I hope this helps someone sometime!
Good luck coding!

Collapse
 
hj1105 profile image
hj1105

I have a question.
In my python code, I use pyqt5, openpyxl, pandas.
And I load some data from excel and take picture using cam and save the picture in same path.
My code works well in my spyder, but it doesn't work when I made exe file.
Should I have to add more options?

Collapse
 
eshleron profile image
Eshleron • Edited

Hi! What exactly doesn't work when you run it as .exe?

Collapse
 
hj1105 profile image
hj1105

More explain about excel file, I need to read and write the excel file.

Collapse
 
drunkcodes profile image
Aneke Emmanuel Chidubem

Hello,
I wrote an automation PY script. The script is working fine when tested on my IDE.

I created .exe file through your guide.
I lunched the application it opened fine. Everything was complete.

The problem is that when I tried to run automation it will open the web browser but will not automate anything.

Is they a way you can help me out

Collapse
 
eshleron profile image
Eshleron

Hi!

Send me an error code if sometime there will be one.
List all libs you use. I think one of them works that way.
And try to launch your app from cmd, see if there is anything there.

Collapse
 
drunkcodes profile image
Aneke Emmanuel Chidubem

I have fixed it using Auto py to exe.
I had to add some codes and move some files. It works now. But when I install it I can't find the software lunch icon on Desktop . Had to always go to my folder to lunch it. Is they a way to have it on my Desktop

Thread Thread
 
eshleron profile image
Eshleron

Glad you fixed it!
I dont remember this option being there. I think by default it saves the result near initial script location.

Collapse
 
jromano1 profile image
JPR

I'm a VERY inexperienced python user, but have built a couple of very basic scripts with an small interactive UI (using Tkinter/pyodbc).

My question is - once the script is converted to .exe and distributed to the users (who will save and launch from the desktops), do they need to have anything else installed, or is the .exe truly fully self contained?

My goal is to be able to write a script, convert to an executable, send to my users, and have them use that for some basic daily work.

Thanks!

Collapse
 
eshleron profile image
Eshleron • Edited

Hi! To use .exe an end user doesn't need anything. Once it's .exe and not .py format your script should be usable without any additional software. Check for correct paths if you're opening smt inside your program.

But make sure (if you work with SQL DB) that it's packed with evething it needs. I haven't tried to work with DB and PyInstaller so I dont know how it will be able to pack it. I guess to PyInstaller it's just the same library as any other.

Collapse
 
jromano1 profile image
JPR

Thank you for the reply!

It seems that that's not always the case, and the converted .exe doesn't always contain the same stuff.

For example, and I apologize for not having the code and error messages anymore... I had a script (in PyCharm) that pulled a 2 values from a SQL table, then just subtracted them and printed out the difference (up to the thenth position). It worked fine, but once I converted it, I received an error that the "Decimal" module/library could not be found. I never called "Decimal", but one of my colleagues said it was part of the standard python installation. So we assumed the issue, then, was that the "Decimal" library/module/package was excluded from the final build.

I've since been unable to resolve this problem and built the app using something else, but I'd love to try again sometime.

Collapse
 
celiasty profile image
Celiasty

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

Collapse
 
eshleron profile image
Eshleron • Edited

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.

Collapse
 
headdawn profile image
Sertan ÖZCAN

Hi;

ModuleNotFoundError: No module named 'talib.stream'
[14920] Failed to execute script algotrade

how can i solve this problem?

Thanks.

Collapse
 
arthur10vieira profile image
arthur10vieira

Hello Sertan, all right?

I managed to solve this problem through a spec file that is in the directory as shown in the images shown

dev-to-uploads.s3.amazonaws.com/up...

Open the notepad ++ editor to edit the specifications file as shown in the image below

dev-to-uploads.s3.amazonaws.com/up...

Put the 'talib.stream' module on hiddenimports and save file spec

dev-to-uploads.s3.amazonaws.com/up...

Execute instruction with pyinstaller as an example below

pyinstaller yournamefile.spec

dev-to-uploads.s3.amazonaws.com/up...

After your executable file has been generated, run it and confirm that it worked for you

I hope to help you, I found out by researching the missing module and managed to overcome it

Collapse
 
dkmaurya82 profile image
dinesh

Thank you for a great research and solution. It has worked for me now my .exe file is running.

Collapse
 
aadarsh_af profile image
Aadarsh

Hello @eshleron First of all thanks for creating this wonderful GUI App which would help developers convert their scripts, which again propose a GUI App, into a user friendly app!
I've made so many apps using pyinstaller and cx_freeze whichever whenever needed. They're truly a blessing!
Now basically I've created a tkinter script which shows the user latest News and Weather updates using API_KEYS(one for news and the other for weather)... And now when I'm packaging it (by adding all the extra scripts and files it'd need) into an exe file using pyinstaller or cx_freeze... Both the exe files show errors related to the API_KEY of weather app while the script works perfectly fine! I'm attaching images of the errors from both packagers

Error from the Pyinstaller Exe file
The above image is of the error from the Pyinstaller Exe file

Error from the Cx_Freeze exe file
The above image is of the error from the Cx_Freeze Exe file (KeyError 'aadarsh' means that the name I gave to my api_key in the config file)

I have gone through most of the google advices which were from Github, StackOverflow, and many likely sites... I've added snippets to my requests library files and also in the pyinstaller hook folder as per the advices but no change could be found in every other exe file created.... (well the hook advice was helpful earlier when i worked with pydocx library and pyinstaller)

Also please tell me how to contact you by messaging... I need help regarding other programming stuffs too! This one is urgent though

Collapse
 
eshleron profile image
Eshleron

Hi!
Thank you for the kind words regarding the app. Unfortunately for me I am not the author but I completely share your excitement and gratitude towards one.

As for the errors. I think the path solution is worthy of trying first (you can find it in this article under "one file" section)

Try it and see where it leeds.

Collapse
 
sanchit1219 profile image
sanchit Kedia

Hi, i am reading data from an excel using pandas in the code. How should i write the path for the excel such that when i send the "one dir" file to another user it doesn't give the error "no such file or directory".

Collapse
 
eshleron profile image
Eshleron

Hi!
I think you just have to make sure when you open the file in your app that the file is there. So you should send a copy to other user so the original stays there or you delete this one and create a new one with the same name.
I think if the file is not present in the directory when you try to open it it will trigger the exception, but otherwise it shouldn't.

Collapse
 
armanniko profile image
ArmanNiko

Hey there!

I'm programming with pygame. I have done whatever was in the post but it still gives me fatal error when i run the .exe file. I'm using one file and windowed, and I've written the resource_path function in my code. and I've used it like this:
image1 = pygame.image.load(resource_path('filename.png'))
I wanted to ask is this correct? and if it is then why am i having trouble running the .exe file. and if it's not, then what else should i do?

Collapse
 
eshleron profile image
Eshleron

Hi!
I've never used pygame, so regarding that I'm not competent to give any advice.

But what I think might be happening:

  1. Image format(.png) What I found on pygame.org
    "pygame may not always be built to support all image formats. At minimum it will support uncompressed BMP. If pygame.image.get_extended() returns 'True', you should be able to load most images (including PNG, JPG and GIF)."
    I'd check that first.

  2. The way the image is loaded. Kind of through another function. I'd separate the code, meaning creating image first(path to image or you can try creating image object), than loading it, checking if everything is OK.

Anyway, without any extended code or error messages I can do more than guess.

Collapse
 
catalinaaguilera profile image
CatalinaAguilera

Hola!! Tengo una app python 3.6... dos ventanas la de inicio es .ui (qt designer) y la segunda esta creada en qt designer pero es .py... además utilizo pycharm y compila todo lo mas bien...
ahora cuando utilizo pyinstaller tengo varios problemas, el primero es upx not available
alguna solucion??
gracias!!

Collapse
 
eshleron profile image
Eshleron

Hi! I speak only ENG and RUS unfortunately. And autotranslation doesn't do a good job of translating.

Collapse
 
cccc1414 profile image
cccc1414 • Edited

Hi! I managed to convert the file but I'm facing some issues. These buttons will directly link to google chrome and display plotly graphs. However, the modules are not included. For example "No module named 'plotly'"

What can I do to make it work?

Thank you so much!

Collapse
 
eshleron profile image
Eshleron

Hi!
Try to include them using Auto py to exe. I think in advanced you can include libs that you need.
If that doesn't work then copy them inside the converted folder.

Collapse
 
blackpearl225 profile image
Blackpearl225

Hey there, i've been running into an error since last week. I tried to create a executable from a python file and everything worked fine except the fact that i had a console open when the exe was running. So i decided to use the --noconsole command in order to hide it and then the exe won't start . I got the error "failed to execute script". Coud anyone help me out?
Thanks you very much.

Collapse
 
eshleron profile image
Eshleron

Hi!
If youneed to hide the console you can choose the option in Auto py to exe to hide it.

Collapse
 
kuajonieto profile image
franco nieto

Hi, nice post!! It works perfectly. Im compiling the aplication in a 64 (x86) bits system, i wanna know if there is any way to make the programm works in a 32 bits system. Or i have to compile it in a 32 bit system?

Collapse
 
eshleron profile image
Eshleron • Edited

Hi!
I think 64/32 bit depends on the libraries you choose to include.
For example, you only have 1 lib in your project.
If you install Python 32bit and PyQt 32bit, compile it, then it should work with 32 bit system.

Collapse
 
mansisharma07 profile image
mansi-sharma07

hey, I got this error

ERROR: Command errored out with exit status 1:
command: 'c:\users\mansi sharma\appdata\local\programs\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Mansi Sharma\AppData\Local\Temp\pip-install-1xntxbrx\gevent\setup.py'"'"'; file='"'"'C:\Users\Mansi Sharma\AppData\Local\Temp\pip-install-1xntxbrx\gevent\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Mansi Sharma\AppData\Local\Temp\pip-install-1xntxbrx\gevent\pip-egg-info'
cwd: C:\Users\Mansi Sharma\AppData\Local\Temp\pip-install-1xntxbrx\gevent\
Complete output (113 lines):
Traceback (most recent call last):
File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
return self.find_available_vc_vers()[-1]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
    yield saved
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
    exec(code, globals, locals)
  File "C:\Users\MANSIS~1\AppData\Local\Temp\easy_install-brfbx698\cffi-1.14.0\setup.py", line 127, in <module>
    HUB_PRIMITIVES = Extension(name="gevent.__hub_primitives",
  File "C:\Users\MANSIS~1\AppData\Local\Temp\easy_install-brfbx698\cffi-1.14.0\setup.py", line 105, in uses_msvc
    include_dirs=include_dirs)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\command\config.py", line 225, in try_compile
    self._compile(body, headers, include_dirs, lang)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\command\config.py", line 132, in _compile
    self.compiler.compile([src], include_dirs=include_dirs)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\_msvccompiler.py", line 360, in compile
    self.initialize()
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\_msvccompiler.py", line 253, in initialize
    vc_env = _get_vc_env(plat_spec)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
    return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 843, in __init__
    self.si = SystemInfo(self.ri, vc_ver)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 485, in __init__
    self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
    raise distutils.errors.DistutilsPlatformError(err)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Mansi Sharma\AppData\Local\Temp\pip-install-1xntxbrx\gevent\setup.py", line 427, in <module>
    run_setup(EXT_MODULES, run_make=_BUILDING)
  File "C:\Users\Mansi Sharma\AppData\Local\Temp\pip-install-1xntxbrx\gevent\setup.py", line 328, in run_setup
    setup(
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\__init__.py", line 144, in setup
    _install_setup_requires(attrs)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\__init__.py", line 139, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\dist.py", line 716, in fetch_build_eggs
    resolved_dists = pkg_resources.working_set.resolve(
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\pkg_resources\__init__.py", line 780, in resolve
    dist = best[req.key] = env.best_match(
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\pkg_resources\__init__.py", line 1065, in best_match
    return self.obtain(req, installer)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\pkg_resources\__init__.py", line 1077, in obtain
    return installer(requirement)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\dist.py", line 786, in fetch_build_egg
    return cmd.easy_install(req)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 679, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 705, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 890, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 1158, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\command\easy_install.py", line 1144, in run_setup
    run_setup(setup_script, args)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 253, in run_setup
    raise
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 166, in save_modules
    saved_exc.resume()
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 141, in resume
    six.reraise(type, exc, self._tb)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\_vendor\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
    yield saved
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
    exec(code, globals, locals)
  File "C:\Users\MANSIS~1\AppData\Local\Temp\easy_install-brfbx698\cffi-1.14.0\setup.py", line 127, in <module>
    HUB_PRIMITIVES = Extension(name="gevent.__hub_primitives",
  File "C:\Users\MANSIS~1\AppData\Local\Temp\easy_install-brfbx698\cffi-1.14.0\setup.py", line 105, in uses_msvc
    include_dirs=include_dirs)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\command\config.py", line 225, in try_compile
    self._compile(body, headers, include_dirs, lang)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\command\config.py", line 132, in _compile
    self.compiler.compile([src], include_dirs=include_dirs)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\_msvccompiler.py", line 360, in compile
    self.initialize()
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\distutils\_msvccompiler.py", line 253, in initialize
    vc_env = _get_vc_env(plat_spec)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
    return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 843, in __init__
    self.si = SystemInfo(self.ri, vc_ver)
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 485, in __init__
    self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
  File "c:\users\mansi sharma\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
    raise distutils.errors.DistutilsPlatformError(err)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Collapse
 
eshleron profile image
Eshleron

Seems like "Microsoft Visual C++ 14.0 is required".

Collapse
 
leandadearaujo profile image
leandadearaujo • Edited

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

Collapse
 
eshleron profile image
Eshleron • Edited

Hi! Can you please send some screenshots?

Collapse
 
claudiaacerra profile image
claudia acerra

Wow did not know this app was out there. Thank you for your hard work. I have been trying to use pyinstaller to distrinute my tkinter app with SQLite DB... The error I get using pyinstaller is the same one I get using your tool. And that is when I try and use data from the DB or try to update the DB I get the following error:

sqlite3.OperationalError: no such table: track2

Any ideas?
Again thank you!

Collapse
 
eshleron profile image
Eshleron • Edited

Hi!
Try this solution on stackoverflow

Check out this method to making sure that you are working in the right directory.
one way to do it

Let me know if that helps or not!

Collapse
 
drpetermulhall profile image
DrPeterMulhall

Hi,
I'ma first time use and can't get the program to work (I know I'm missing something) - can you help?

Output from the command prompt:

Mulhall@Mulhall-PC MINGW64 /e/python/projects/weighted-kappa/newexe (master)
$ auto-py-to-exe
Traceback (most recent call last):
File "", line 41, in
File "", line 36, in walk_packages
File "", line 36, in walk_packages
File "", line 20, in walk_packages
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\admin_init.py", line 5, in
from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\admin\options.py", line 2, in
from django.contrib.gis.admin.widgets import OpenLayersWidget
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\admin\widgets.py", line 3, in
from django.contrib.gis.gdal import GDALException
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\gdal__init
_.py", line 28, in
from django.contrib.gis.gdal.datasource import DataSource
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in
from django.contrib.gis.gdal.driver import Driver
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 39, in
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
Traceback (most recent call last):
File "c:\users\mulhall\appdata\local\programs\python\python38-32\lib\site-packages\gevent_ffi\loop.py", line 268, in python_check_callback
def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument
KeyboardInterrupt
2020-05-10T16:08:25Z

Many thanks

Peter

Collapse
 
eshleron profile image
Eshleron

Hi!

I'm not sure what the problem is. Try to reinstall GDAL as error message says or Django itself.

Collapse
 
lyfolos profile image
Muhammed H. Alkan

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

Collapse
 
vguarnaccia profile image
Vincent Guarnaccia

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

Collapse
 
adorabletrooper profile image
Adorable trooper

I just saw your post and then I applied it to my personal project. But .exe file was showing error "Fatal Error!" "Failed to run script". I am having files which include .py files , .png files and .db files. Please find an attachment for an img showing all the files in the directory. I haven't done any thing with my app script yet. Please give me detailed directions to get out from this Error.

Collapse
 
eshleron profile image
Eshleron

Hi!
Please provide screenshots of errors or some code so I can help.

Collapse
 
guneet999 profile image
Guneet Singh

I want to convert complete Django project in exe, I did that using pyinstaller and dist containing the exe file I am running batch file, working fine, but transferring to another person, its not working.

Collapse
 
khanalim profile image
khanalim

Hello, I have made exe file of a python script. My text editor is PyCharm. Exe file shows unix installer. Everything works on my Mac, but whenever, I transfer my exe files or folder to another pc or Mac, that computer does not recognize the exe file.

I am totally lost. Anyone has any suggestions.

Collapse
 
eshleron profile image
Eshleron

Hi! If you're using any paths to directories or files do check that. Also use try/except clause and run stuff in cmd/terminal to see the errors if you don't have a GUI.

Collapse
 
bouazizaitd profile image
Bouaziz-aitd

I am fairly new to Python. I use spyder IDE and have crated miniconda3 environments. I have two environments (base) that came with the installation and one (GIS) I created. I installed additional packages in the latter as being related to my projects. I installed the auto-py-to-exe using pip as the conda did not recognize it. I compiled a simple plot program that uses matplotlib and when running the onefile exe I get an error that matplotlib is not defined.
I got the following in the output window from auto-py-to-exe :
Running auto-py-to-exe v2.32.0
Building directory: C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad
Provided command: pyinstaller --noconfirm --onefile --windowed "C:/Users/baitdriss/Desktop/Temporaire/Python Learning/test.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onefile --windowed C:/Users/baitdriss/Desktop/Temporaire/Python Learning/test.py --distpath C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\application --workpath C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\build --specpath C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad

319792 INFO: PyInstaller: 5.9.0
319812 INFO: Python: 3.9.16 (conda)
319859 INFO: Platform: Windows-10-10.0.19044-SP0
319869 INFO: wrote C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\test.spec
319921 INFO: UPX is not available.
319962 INFO: Extending PYTHONPATH with paths
['C:\Users\baitdriss\Desktop\Temporaire\Python Learning']
321311 INFO: checking Analysis
321343 INFO: Building Analysis because Analysis-00.toc is non existent
321359 INFO: Initializing module dependency graph...
321411 INFO: Caching module graph hooks...
321498 INFO: Analyzing base_library.zip ...
328990 INFO: Loading module hook 'hook-encodings.py' from 'C:\Users\baitdriss\AppData\Roaming\Python\Python39\site-packages\PyInstaller\hooks'...
334212 INFO: Loading module hook 'hook-pickle.py' from 'C:\Users\baitdriss\AppData\Roaming\Python\Python39\site-packages\PyInstaller\hooks'...
336908 INFO: Loading module hook 'hook-heapq.py' from 'C:\Users\baitdriss\AppData\Roaming\Python\Python39\site-packages\PyInstaller\hooks'...
339809 INFO: Caching module dependency graph...
340211 INFO: running Analysis Analysis-00.toc
340333 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\ProgramData\miniconda3\python.exe
342737 INFO: Analyzing C:\Users\baitdriss\Desktop\Temporaire\Python Learning\test.py
342760 INFO: Processing module hooks...
342841 INFO: Looking for ctypes DLLs
342857 INFO: Analyzing run-time hooks ...
342899 INFO: Looking for dynamic libraries
346010 INFO: Looking for eggs
346020 INFO: Using Python library C:\ProgramData\miniconda3\python39.dll
346028 INFO: Found binding redirects:
[]
346045 INFO: Warnings written to C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\build\test\warn-test.txt
346142 INFO: Graph cross-reference written to C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\build\test\xref-test.html
346311 INFO: checking PYZ
346326 INFO: Building PYZ because PYZ-00.toc is non existent
346334 INFO: Building PYZ (ZlibArchive) C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\build\test\PYZ-00.pyz
346998 INFO: Building PYZ (ZlibArchive) C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\build\test\PYZ-00.pyz completed successfully.
347049 INFO: checking PKG
347055 INFO: Building PKG because PKG-00.toc is non existent
347077 INFO: Building PKG (CArchive) test.pkg
354176 INFO: Building PKG (CArchive) test.pkg completed successfully.
354208 INFO: Bootloader C:\Users\baitdriss\AppData\Roaming\Python\Python39\site-packages\PyInstaller\bootloader\Windows-64bit-intel\runw.exe
354223 INFO: checking EXE
354255 INFO: Building EXE because EXE-00.toc is non existent
354286 INFO: Building EXE from EXE-00.toc
354297 INFO: Copying bootloader EXE to C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\application\test.exe.notanexecutable
354823 INFO: Copying icon to EXE
354872 INFO: Copying icons from ['C:\Users\baitdriss\AppData\Roaming\Python\Python39\site-packages\PyInstaller\bootloader\images\icon-windowed.ico']
354880 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
354910 INFO: Writing RT_ICON 1 resource with 3752 bytes
354920 INFO: Writing RT_ICON 2 resource with 2216 bytes
354934 INFO: Writing RT_ICON 3 resource with 1384 bytes
354949 INFO: Writing RT_ICON 4 resource with 38188 bytes
354959 INFO: Writing RT_ICON 5 resource with 9640 bytes
354981 INFO: Writing RT_ICON 6 resource with 4264 bytes
355013 INFO: Writing RT_ICON 7 resource with 1128 bytes
355212 INFO: Copying 0 resources to EXE
355222 INFO: Embedding manifest in EXE
355233 INFO: Updating manifest in C:\Users\BAITDR~1\AppData\Local\Temp\tmpoutj0wad\application\test.exe.notanexecutable
355248 INFO: Updating resource type 24 name 1 language 0
355444 INFO: Appending PKG archive to EXE
355498 INFO: Fixing EXE headers
356262 INFO: Building EXE from EXE-00.toc completed successfully.

Moving project to: C:\Users\baitdriss\Desktop\Temporaire\Python Learning\dist
Complete.

I got also this message on the CMD prompt:
(base) PS C:\WINDOWS\system32> auto-py-to-exe
1383 INFO: Extra DLL search directories (AddDllDirectory): []
1383 INFO: Extra DLL search directories (PATH): ['C:\ProgramData\miniconda3', 'C:\ProgramData\miniconda3\Library\mingw-w64\bin', 'C:\ProgramData\miniconda3\Library\usr\bin', 'C:\ProgramData\miniconda3\Library\bin', 'C:\ProgramData\miniconda3\Scripts', 'C:\ProgramData\miniconda3\bin', 'C:\ProgramData\miniconda3\condabin', 'C:\Program Files\Common Files\Oracle\Java\javapath', 'C:\ProgramData\Oracle\Java\javapath', 'C:\WINDOWS\system32', 'C:\WINDOWS', 'C:\WINDOWS\System32\Wbem', 'C:\WINDOWS\System32\WindowsPowerShell\v1.0', 'C:\WINDOWS\System32\OpenSSH', 'c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn', 'c:\Program Files\Microsoft SQL Server\100\Tools\Binn', 'c:\Program Files\Microsoft SQL Server\100\DTS\Binn', 'C:\Program Files (x86)\QuickTime\QTSystem', 'C:\Program Files\dotnet', 'C:\Program Files (x86)\Box\Box Edit', 'C:\Users\baitdriss\AppData\Roaming\Python\Python39\Scripts', '.']

Any help willl be highly appreciated.

Collapse
 
eshleron profile image
Eshleron

Hi! It is hard to say for sure what is the issue in your case since you have a number of environments. I would suggest looking into installing auto-py-to-exe not with pip in this case. But with something more easily recognizable by conda(depends if conda is set in PATH and as a default interpreter). If nothing that you do works, try using a separate IDE like PyCharm to test the project and also the auto-py-to-exe settings that you use to exclude that as a potential problem.

Collapse
 
fjo_costa profile image
Fernando Costa

Nice!! How does this handle zipfile?

Collapse
 
eshleron profile image
Eshleron • Edited

If I understood your quiestion correctly then that's what I found pythonhosted.org/PyInstaller/advan...

Collapse
 
tejasmandre profile image
Tejas Mandre

Does this pack all the libraries that need to be imported in my python code in my .exe file ?

Collapse
 
eshleron profile image
Eshleron

Yes, it does.

Collapse
 
teambug2000 profile image
teambug2000

my script have some packages: tensorflow, opencv, pandas, etc
Can I have to pre install on a non py computer, or just run this AUTO EXE and then execute it ? thanks alot!

Collapse
 
eshleron profile image
Eshleron

You should be able to execute it without preinstallation if I understood your question correctly.

Collapse
 
biswarup1290dass profile image
biswarup1290dass

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

Collapse
 
fatmaelsherif profile image
Fatma-Elsherif

SystemExit: Unable to find "C:\Users\medo2\nltk_data" when adding binary and data files.

Project output will not be moved to output folder
Complete.

Collapse
 
biswarup1290dass profile image
biswarup1290dass

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...]

Collapse
 
eshleron profile image
Eshleron

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.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
eshleron profile image
Eshleron

Hi! Check if your program has any threads that need closing.

Collapse
 
sandynoddy profile image
Sarthak Khare

I am using Python 3.8 and getting an error as failed to execute script ....

Collapse
 
eshleron profile image
Eshleron

Hi!

I haven't tried to run Auto PY to EXE on anything later than 3.6. I think there should be information about supported versions of Python on the official page of Auto PY to EXE.

Collapse
 
doniamariadenny profile image
doniamariadenny

after converting .py to .exe how do i send it to someone through gmail??
pls help

Collapse
 
drunkcodes profile image
Aneke Emmanuel Chidubem

I created the exe file according to your guide but it doesn't automate web browser as it does on IDE. It only opens the web browser but does nothing.

Collapse
 
carolinatc profile image
CarolinaTC

Hi all!
Can anyone help me? I try to create the exe and its ok, but when i try open it, doesn't work...
Anyone have this issue?
Thanks

Collapse
 
eshleron profile image
Eshleron

Please provide snippets of code or a screenshot of an error message

Collapse
 
how2code profile image
Info Comment hidden by post author - thread only accessible via permalink
How2Code

Well, 1st this isn't a .py into a .exe file, it's a .py into a .pyc so this tutorial is automaticly fake, but no matter is it a .exe or a .pyc file, it does work properly, so I don't really care.

Collapse
 
sandynoddy profile image
Sarthak Khare

I am using python 3.8 and getting error as script failed to execute script

Collapse
 
rlp81 profile image
rlp81

Ok, so I don't know why but Windows power shell doesn't recognize the command even though it's downloaded I've even found Auto-py-to-exe in my python packages.

Collapse
 
eshleron profile image
Eshleron

Hi! Check PATH variables

Collapse
 
galzah2000 profile image
galzah2000

Does not work. It creates an .exe file, but when opened it displays this: ModuleNotFoundError: No module name 'matplotlib

Collapse
 
eshleron profile image
Eshleron

Если библиотека не добавляется в упаковщик, попробуйте добавить ее вручную. Также попробуйте добавить библиотеку с помощью настроек в Auto PY to EXE.

Collapse
 
antojeffry profile image
antojeffry

Image description

hey i am facing this problem.What might be the fix

Collapse
 
eshleron profile image
Eshleron

Hi. Look into the google-cloud-core. It is used in someway in your code directly or as a dependency.

Some comments have been hidden by the post's author - find out more