Hongmu Notes
Home Language Notes How does python package and run on Windows?
Language Notes python

How does python package and run on Windows?

How does python package and run on Windows?

The most common way to package and run Python programs on Windows is to use PyInstaller. PyInstaller is a free and cross-platform Python application packaging tool, which can package Python code and its dependent libraries into an independent executable file, making it possible to run Python programs on systems without Python interpreters installed.

The following are the basic steps to package Python programs with PyInstaller:

  1. Install PyInstaller

Install PyInstaller with pip command:

pip install pyinstaller
  1. Write Python programs

Write your Python program and test it to make sure it works properly.

  1. Packer

Use the command line to enter the directory where the Python program is located, and execute the following command:

pyinstaller your_program.py

This command will automatically package the program into an executable file and output it to the dist folder.

  1. working procedure

Find the generated executable file in the dist folder, and double-click Run. Your program should be able to run normally on a system without Python interpreter.

Note: When packaging, you need to pay attention to whether the libraries that the program depends on are also packaged correctly, especially some third-party libraries and non-Python standard libraries. If the program doesn't work properly, you can try using.--debugParameter to view the error information in the packaging process.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Import " requests" could not be resolved from source

Import " requests" could not be resolved from source Language Notes python

This error occurred when using Pylance, a Python language server. Among them, " Import " requests" could not be resolved from source" This error message indicates that the requests module is referenced in your code, but Pylance cannot find the location of the module from the source. The possible reason is that you don't have an …
👁 1771
Reinstall Python and requests libraries

Reinstall Python and requests libraries Language Notes python

If you meet " Import " requests" could not be resolved from source" You can try reinstalling Python and requests libraries. First, you need to uninstall the current Python and requests libraries. On Windows systems, you can use the command prompt …
👁 439
WARNING: Skipping requests as it is not installed.

WARNING: Skipping requests as it is not installed. Language Notes python

This error message indicates that your Python environment lacks the requests library, and this library is called in your code, so Python cannot execute your code normally. The solution to this problem is to install the requests library. You can use the pip command on the command line to install: pip install requests If you are using Python3, you can use the pip3 command …
👁 2100
Python reported an error. What is the reason? AttributeError: partially initialized module ' openai'  has no attribute ' Completion' (most likely due to a circular import)

Python reported an error. What is the reason? AttributeError: partially initialized module ' openai' has no attribute ' Completion' (most likely due to a circular import) Language Notes python

This error prompt indicates that there is a problem when importing the openai module and the specific Completion attribute, which is probably caused by circular import. The reason for this error may be that two or more modules in your code are imported from each other, forming a circular dependency. For example, module A imports module B, and module B imports module A.. Cyclic import will cause the module not to initialize correctly when loading, thus …
👁 656
What programming software is good for python development?

What programming software is good for python development? Language Notes python

There are many programming softwares developed by Python. The following are some commonly used Python integrated development environments (IDE) and editors: PyCharmPyCharm is an integrated development environment developed by JetBrains, which is specially designed for Python developers. PyCharm is powerful and provides a series of advanced functions such as code completion, debugging, version control, code refactoring, etc., which can help developers improve their work …
👁 175
What does `if __name__ == '__main__' ` mean in Python?

What does `if __name__ == '__main__' ` mean in Python? Language Notes python

`if __name__ == '__main__':` is a commonly used conditional statement in Python that allows a Python file to be executed as an independent script or imported as a module by other Python scripts. Specifically, when a Python file is run as a script, the `if __name__ == '__main__':` clause...
👁 136

Recommended reading

(PC+WAP) Blue Glass Fiber Products Website pbootcms Template Marketing Environmental Protection Equipment Website Source Download 0573

(PC+WAP) Blue Glass Fiber Products Website pbootcms Template Marketing Environmental Protection Equipment Website Source Download 0573 Practical Collection pbootcms Template

A blue glass fiber products and environmental protection equipment industry PbootCMS website template, supporting PC and WAP. The design style is concise and professional, which can show the application scenarios and performance advantages of FRP products. It is helpful for composite materials or environmental protection equipment enterprises to show their product strength online and acquire customers. Template display installation instructions website background: /admin.php account number: admin password: admin decompression password: www…
👁 56
How can the data table rearrange the primary key from 1 without affecting other contents?

How can the data table rearrange the primary key from 1 without affecting other contents? Language Notes mySql Summary of pitfalls

After studying all morning, I finally found a solution. One primary table and one secondary table, and want to rearrange the primary keys of two tables at one time. Originally said to rely on PHP to traverse processing, the result is outrageous, too slow, so directly on SQL code processing! SQL Code: Hidden Content: View after comments # Create Item _ Instance _ New Create Table Item _ Instance _ N …
👁 204
Responsive digital electronic website template 1021

Responsive digital electronic website template 1021 Practical Collection Yiyou template

This set of eyoucms responsive templates is suitable for the digital electronics industry. The design style is scientific and fashionable, and it can display digital products, electronic equipment, technical parameters and brand image. It is helpful for digital brands to display their products online and attract technology enthusiasts and consumers. Template Display Installation Instructions Website Background: /login.php Account: admin Password: admin Related Articles Easy CMS Installation FAQ Summary Easy CMS…
👁 56
What should I do if the Redis Object Cache plug-in cannot be linked after wordpress redis changes the password?

What should I do if the Redis Object Cache plug-in cannot be linked after wordpress redis changes the password? Program Notes wordpress

Problem description: My wordpress site server uses pagoda panel, installed php8.0, and installed redis on the extension panel, and installed Redis Object Cache plug-in in wordpress. In fact, in general, you don't need to do anything, just start it directly. However, it is unsafe for radis not to set a password, which is a risky loophole, so I still think it is better to set a password, …
👁 256
Responsive light source photoelectric lighting R&D website template 0199

Responsive light source photoelectric lighting R&D website template 0199 Practical Collection Yiyou template

This set of eyoucms responsive templates is suitable for light source, photoelectric lighting and R&D industries, and its design style is scientific and energy-saving, which can show lighting products, photoelectric technology, R&D achievements and engineering cases. It is helpful for photoelectric enterprises to show their technical strength online and attract customers. Template display installation instructions website background: /login.php account number: admin password: admin related articles Yiyou CMS installation FAQ summary Yiyou CM…
👁 42
(PC+WAP) Semiconductor electronic equipment website pbootcms template Blue electronic technology product website source code download 0574

(PC+WAP) Semiconductor electronic equipment website pbootcms template Blue electronic technology product website source code download 0574 Practical Collection pbootcms Template

A blue PbootCMS website template for the semiconductor and electronic equipment industry, supporting PC and WAP. The design style has a strong sense of technology and can well present the professional image of electronic components, chips and technology products. The template has built-in product display, technical information and industry news modules, making it a convenient choice for electronic technology companies to build official brand websites. Template display Installation instructions Website backend:/admin.php Account: admin Password…
👁 46