Home  >  Article  >  Backend Development  >  How to make a Python script an exe file that runs in a Windows environment

How to make a Python script an exe file that runs in a Windows environment

不言
不言Original
2019-01-23 16:09:072657browse

The exe file is an executable file that allows the PC to execute it as it is. Because it is an executable file, you only need to double-click it to start processing. In addition, the extension is ".exe", which is often used in the Windows environment. This document In this article, we will introduce how to make a Python script become an exe file running in the Windows environment.

How to make a Python script an exe file that runs in a Windows environment

Convert the program to an exe file

Let’s first introduce how to use the tool Pyinstaller

Install Pyinstaller

We use pip to install Pyinstaller.

Note that if you use Pyinstaller, you should use an environment with python 2.7 or python 3.3 to python 3.6 (as of July 2018).

The installation method is very simple, we execute the following command

$ pip install pyinstaller

Next we convert the python script into an exe file

We will ".py" Convert file to ".exe" file

First, we create the original ".py" file.

This time use the following file (test.py) that displays "Hello World!"

#! /usr/bin/env python
# coding: UTF-8
 
print("Hello World!")

When converting, execute the following command.

$ pyinstaller test.py

You can see that the above test.py process has been completed.

Hello World!

This article ends here. For more exciting content, you can pay attention to other related column tutorials on the php Chinese website! ! !

The above is the detailed content of How to make a Python script an exe file that runs in a Windows environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn