How do you compile .py to .exe in Microsoft Visual Studio 2017? I have looked through the menus but can not find what I'm looking for?
In this section, we can also modify the path for where we want to export the files generated by our executable file: to do this, select the “Settings” toggle option and browse to the output directory of your choosing. The last step is to select “Convert . py to .exe” to convert our Python file.
Run the code by pressing Ctrl+F5 or selecting Debug > Start without Debugging. You can also select the toolbar button that shows the startup item with a play button, which runs code in the Visual Studio debugger.
Visual Studio provides open-source support for the Python language through the Python Development and Data Science workloads (Visual Studio 2017 and later) and the free Python Tools for Visual Studio extension (Visual Studio 2015 and earlier).
Select the Python Application template, and select Next. On the Configure your new project screen, specify a name and file location for the project, and then select Create. The new project opens in Visual Studio. The Visual Studio Solution Explorer window shows the project structure (1).
You can compile it, but only into a .pyc file which is a compiled python file, which I do not know what it does. I personally chose to installed pyinstaller, and ran pyinstaller [filename].py
from the command line. It is easier than py2exe.
Python is usually not compiled but executed using the python interpreter.
You should only ever compile it to an .exe if you want to execute it on windows without having to install python first. That can be done by using pyinstaller or py2exe (in case you use python 2).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With