Reputation: 51
I would like to compile a Python3 project with cx_Freeze, but no matter what I do I can never import my own .py
files.
Here's my directory structure:
projectname/
setup.py
app/
code/
__init__.py
config.py
run.py
run - editeur.py
...
image/
...
level/
...
My setup.py
:
import sys, os
from cx_Freeze import setup, Executable
path = sys.path
includes = []
excludes = []
packages = ["app/code"]
includefiles = ["app/image", "app/level"]
optimize = 0
silent = True
options = {"path": path,
"includes": includes,
"excludes": excludes,
"packages": packages,
"include_files": includefiles,
"optimize": optimize,
"silent": silent
}
base = Win32GUI
cible_1 = Executable(
script="app/code/run.py",
)
cible_2 = Executable(
script="app/code/run - editeur.py",
)
setup(
name="project",
version="1.0",
description="blabla",
options={"build_exe": options},
executables=[cible_1, cible_2]
)
The cx_Freeze compilation is going well and I get my 2 executables. But when I try to launch one, every time I get the same error:
[...]
File "app/code/run.py", line 7, in <module>
import config
ImportError: No module named 'config'
I really have to miss something stupid since I have no problem with the plug-ins. It may also be a problem of path or something else I don't know...
Anyone know how to help me a little ? Thanks !
Upvotes: 0
Views: 661
Reputation: 2461
EDIT: I've managed to freeze a simplified example based on your directory structure with the following modification of the setup.py
script:
path = sys.path + ['app/code']
packages = []
Alternatively, you could also try the following structure (modifying the import paths accordingly):
projectname/
setup.py
config.py
run.py
run - editeur.py
...
image/
...
level/
...
Upvotes: 1