Python Forum
auto-py-to-exe with unusual directory structure
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
auto-py-to-exe with unusual directory structure
#1
So I have a fairly large python project with 262 files across 25 folders. The program starts at C:/somepath/main/main/main.py. Given that I have two directories and a file of the same name, and some assets and other python files outside the directory containing main.py, I have no idea on how to use the auto-py-to-exe tool for this. I watched youtube tutorials and read the official README of auto-py-to-exe but the instructions were only for one file/one directory projects, and there was no instructions for this structure.

How should I configure the auto-py-to-exe?

The directory structure looks something like this:

Output:
C:/somepath/main /main __init__.py main.py otherfiles.py /sub __init__.py subfile1.py othersubfile.py ... /othersub __init__.py otherrsubfile.py ... ... /images img1.png img2.png ... /locales /en ... /de ... /fr ... /it ... ...
Reply
#2
There is little sense in having multiple folders of the same name. Have you thought of changing your repo structure so it would be more explicit, e.g.,
Output:
your_project_name docs resources images locales src package1 logic.py gui.py controller.py package2 logic.py gui.py controller.py controller.py
Anyway, I've never used auto-py-to-exe, but pyinstaller works quite fine for me for multi-level projects. I just type pyinstaller project.py and it picks up almost everything automatically.
Reply
#3
After your suggestion, the new file structure is some thing like this:
Output:
C:/Users/Tedu/Desktop/bkchem /src (main folder, previously named bkchem so only the parent and child of src are named bkchem) /oasa /oasa /graph __init__.py basic.py diedge.py ... __init__.py atom.py bond.py ... __init__.py test.py convert.py ... /plugins /piddle __init__.py ... __init__.py cairo.py piddle.py ... __init__.py bkchem.py (the file that executes the script) ... (other files for gui, databases, etc.) /dtd (some special data folder) cdml.dtd cdml.xsd ... /images (directory that stores the splash screen, accepts images from users) icon.ico logo.gif ... /locale (language data) bkchem.pot /fr french.mo /de german.mo /pixmaps (icons for buttons) arrow.gif adder.gif ... /templates (well, templates) ...
When I executed the command pyinstaller -w ./Desktop/bkchem/bkchem/bkchem.py, as per your suggestion, I got these in the prompt (I don't know if they're relevant):

Output:
133 INFO: UPX is not available. 137 INFO: Extending PYTHONPATH with paths ['C:\\Users\\Tedu\\Desktop\\bkchem', 'C:\\Users\\Tedu']
and when I ran the created executable, a dialog box said 'Failed to execute script bkchem'. I'm pretty sure the code worked in Python.
Reply
#4
(Nov-26-2018, 11:09 AM)krow4869 Wrote: When I executed the command pyinstaller -w ./Desktop/bkchem/bkchem/bkchem.py
I would rather cd to the final location and run pyinstaller in the same folder.
Quote:
Output:
133 INFO: UPX is not available. 137 INFO: Extending PYTHONPATH with paths ['C:\\Users\\Tedu\\Desktop\\bkchem', 'C:\\Users\\Tedu']
UPX just compresses EXE files, you don't have to worry about it. Is it your full output? When the program is successfully built, the output is much longer.
Quote:and when I ran the created executable, a dialog box said 'Failed to execute script bkchem'. I'm pretty sure the code worked in Python.
You're missing some modules. Create a copy of your repo, strip it of large third-party libraries, cut down your imports to the minimum and try again.

I should say, building to EXE is not a simple process (at first) and WILL give much headache to those who have never dealt with it. Try building a hello world first, than add GUI, then one-by-one add extra modules. At that point, you will be sure what causes the error. When adding some module fails, that would mean you have to find missing libraries and copy them to your build manually. I had such problem with tkinterhtml and solved it when manually copied Lib/site-packages/tkinterhtml/tkhtml/Windows to folder_with_your_main_built_bin/tkhtml. These are likely to be pre-built platform-dependent binaries that are not being build with pyinstaller during the building process.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unusual Error Led_Zeppelin 1 2,368 Apr-21-2021, 05:42 PM
Last Post: Larz60+
  Unusual things to do with unittest/HTMLTestRunner AndyHolyer 0 2,146 Jul-29-2020, 02:43 PM
Last Post: AndyHolyer
  Create a directory structure across many servers metro17 1 1,754 Nov-05-2019, 03:35 PM
Last Post: Larz60+
  unusual box appears DavidinKorea 1 2,272 Jan-12-2019, 07:42 PM
Last Post: Larz60+
  unusual help compiling python 2 code Bannon 3 3,296 Mar-11-2018, 12:13 PM
Last Post: Bannon
  unusual error message VISHU 1 2,873 Sep-16-2017, 01:57 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020