Usagi
Usagi

Reputation: 45

python - Include other python files in cx_Freeze

I am using cx_Freeze to convert my script to executable. My problem is, the cx_Freeze only executing my main.py and not executing my other .py file that are called by my main.py. How can I include my other python files?

I'm new to cx_Freeze so I hope someone can help me.

Upvotes: 1

Views: 1996

Answers (1)

Xantium
Xantium

Reputation: 11605

You can use the include_files argument in your script. Just add it to your setup script. For example in this short script I made:

from cx_Freeze import setup, Executable

files = {"include_files": ["<Path to Files>/somefile.py", "<Path to file>/someotherfile.py"], "packages": []}

setup(
    name = "Name of app",
    version = "0.1",
    author = "The author",
    options = {'build_exe': files},
    description = "Enter A Description Here",
     executables = [Executable("main.py", base=None)])

You would just put all the files you wanted to include in the files = {"include_files": ["<Path to Files>/somefile.py", "<Path to file>/someotherfile.py"], "packages": []} argument using absolute or relative file paths.

This would copy those files into your build folder.

The second way you could do it is to copy them manually into your build folder but first way of doing it is definitely the best!

Upvotes: 1

Related Questions