Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile .py to .exe in Microsoft Visual Studio Community 2017?

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?

like image 738
Tom Davies Avatar asked Nov 20 '17 09:11

Tom Davies


People also ask

How can I convert a .PY file to a .exe file?

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.

How do I run a Python code in Visual Studio community?

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.

Does Visual Studio community support Python?

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).

How do I run a Python file in Visual Studio 2017?

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).


2 Answers

Hey Tom!

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.

like image 176
Anonymous Avatar answered Sep 18 '22 00:09

Anonymous


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).

like image 42
Maaaaa Avatar answered Sep 22 '22 00:09

Maaaaa