pip install cx_Freeze
python -m pip install cx_Freeze
Python3 won't always be available on every environment. Sometimes the network security team will only allow .exe files or they may not want to install another bit of software on a server.
This make the .py application self-contiained and portable.
Windows environments require the use of two back slashes. The first slash says to ignore the second. Windows...!
-
Install cx_Freeze
-
Set system root directory
rootDir = 'C:\\' # Windows
-
Define the .py file that will get converted to .exe
fileName = 'hello.py'
-
Define the file path where the file located.
If you placed py3exe.py in the same directory as the file you are converting, such as...
py3exe.py hello.py
Then you can use the default which is the current working directory (recommended)
filePath = os.getcwd()
Otherwise you need to specify the absolute path.
filePath = 'C:\\Users\\DrJonesy\\Documents\\current-working-folder'
An alternative for setting the absolute path is
filePath = os.path.join(rootDir, 'Users', 'DrJonesy', 'Document','current-working-folder')
-
Define the python3 location to cxfreeze on your local machine
cxFreezePath = os.path.join(rootDir, "python36", "Scripts", "cxfreeze")
rootDir points to the variable "rootdir", python36 is the folder where this version of python3 is installed, Scripts should be in the python36 folder, and cxfreeze is the Script.
-
In your command window or terminal run the command:
python py3exe.py
-
This will run through a process and create a folder called dist
-
Once the dist folder is created. All the files located in the add-to-root directory sub-folders will be added to the root of the dist directory.
Use the "add-to-root" for adding system compatability files to the root of the "dist" directory. The files must be placed in folder in the "add-to-root". Only one level deep is checked.
|-- add-to-root |-- dll-files |-- vcruntime140.dll
This solves the error for missing VCRUNTIME140.dll
|-- dist
|-- lib
|-- hello.exe (or your file name)
|-- python36.dll
|-- vcruntime140.dll
The lib folder contains all the packages and python file needed to run your application on any environment.
The program was adapted from the YouTube video: https://www.youtube.com/watch?v=gOV3AWiQclg by Technological
[SOLVED] missing VCRUNTIME140.dll