`
aaron_ch
  • 浏览: 177258 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Make python code to exe file

阅读更多

1. Download and install py2exe from the py2exe website

(make sure you download the right version!)

2. Create a directory on you hardisk called mycode ... - Right click on the Windows Desktop and select New .. Folder and name it "mycode"

3. Double click the mycode folder to open it

4. Right click in the folder and select New.. Text Document, name it "hello.txt"

5. Right click in the folder and select New.. Text Document, name it "setup.txt"

6. Double click hello.txt to open it in Notepad

7. Copy the following text into the file and save it:

#Start here
print "Hello py2exe"
raw_input("Press any key to finish")
#End here

8. Double click the setup.txt and copy in the following code (and save the file):

#Start here
from distutils.core import setup
import py2exe

setup(console = ["hello.py"])
#End here

9. Right click on the hello.txt file and rename it to hello.py (ignore the warning)

10. Right click on the setup.txt file and rename it to setup.py (ignore the warning)

11. Start a command console (also called a DOS box) (It is found in the START-> Accessories menu on Windows XP). Alternatiively -start a command console by clicking Start -> Run...  and type cmd<enter> in the dialog.

12. In the console type

cd desktop<enter>

cd mycode<enter>

13. Type

start hello.py<enter>

14. If you entered the code correctly then a new console is created which asks you to press a key

15. The program works so now we can also use py2exe to make a standalone program. Type

start setup.py py2exe<enter>

16. If there are no errors in the setup.py file then py2exe will run. It creates a new sub-directory called dist. Type

cd dist<enter>

17. There should be a file called hello.exe Type:

hello<enter>

18. You have finished. Remember - every file in the dist directory is needed for your hello.exe to run properly. (Zip all the files together and send it to your friends).

 

If you write your own programs they probably won't be called hello.py .

a. Put your python file in the mycode directory

b. Edit setup.py and replace "hello.py" with the name of your own script.

c. Do step 15 above.

Thanks to those of you who made useful comments. 

Have fun! 

分享到:
评论

相关推荐

    Learn to Program with Python

    Get comfortable with the free IDLE Interactive Development Environment (IDE), which you will use to write and debug all your Python code - no need to use the command line! Build text-based programs, ...

    Learn to Program with Python(Apress,2016)

    Get comfortable with the free IDLE Interactive Development Environment (IDE), which you will use to write and debug all your Python code – no need to use the command line! Build text-based programs, ...

    sip for python

    One of the features of Python that makes it so powerful is the ability to take existing libraries, written in C or C++, and make them available as Python extension modules. Such extension modules are ...

    Python安装包version 3.1.5

    Python starting with 2.6 will contain features to help locating code that needs to be changed, such as optional warnings when deprecated features are used, and backported versions of certain key ...

    Python for Bioinformatics 第二版,最新版

    6.2.1 Standard Way to Make Python Code Modular 106 6.2.2 Function Parameter Options 110 6.2.3 Generators 113 6.3 MODULES AND PACKAGES 114 6.3.1 Using Modules 115 6.3.2 Packages 116 6.3.3 Installing ...

    python3.6.5参考手册 chm

    PEP 486: Make the Python Launcher aware of virtual environments PEP 488: Elimination of PYO files PEP 489: Multi-phase extension module initialization Other Language Changes New Modules typing ...

    Python 2.6 Graphics Cookbook.pdf

    interpreter, for MS Windows or Linux as well as how to verify that Python is correctly installed. This chapter explains how to create complete working programs that can be run on client computers ...

    Udemy - Deep Learning Convolutional Neural Networks in Python

    After describing the architecture of a convolutional neural network, we will jump straight into code, and I will show you how to extend the deep neural networks we built last time (in part 2) with ...

    Automate.the.Boring.Stuff.with.Python.Practical.Programming

    Even if you've never written a line of code, you can make your computer do the grunt work. Learn how in Automate the Boring Stuff with Python. Table of Contents Part I. Python Programming Basics ...

    Udemy - Deep Learning Recurrent Neural Networks in Python

    Make sure you always “git pull” so you have the latest version! HARD PREREQUISITES / KNOWLEDGE YOU ARE ASSUMED TO HAVE: calculus linear algebra probability (conditional and joint distributions) ...

    PyQt5_sip-4.19.14-cp37-none-win_amd64.whl

    One of the features of Python that makes it so powerful is the ability to take existing libraries, written in C or C++, and make them available as Python extension modules. Such extension modules are ...

    如何用python制作动态二维码,来哄女朋友开心?.pdf

    【如何用Python制作动态二维码】 在信息技术飞速发展的今天,二维码已经渗透到我们日常生活的方方面面,从支付到信息传递,无处不在。如果你想要给你的女朋友带来一点惊喜,尝试用Python制作一个动态二维码是一个...

    python standerd labrary中文版

    ### Python Standard Library中文版知识点概览 #### 一、前言 - **关于本书** - 本书旨在全面介绍Python标准库中的各个模块及其用法。 - 适合所有水平的Python开发者,无论是初学者还是有经验的程序员都能从中...

    eric5-5.3.1

    This is a tool to check Python code for white-space related problems. It is part of the standard Python installation. profile This is part of the standard Python distribution and is used to ...

    vmware unlocker 2.0.6最新版(vm虚拟机破解安装Mac OS)

    The code requires Python 2.7 to work. Most Linux distros, ESXi and OS X ship with a compatible Python interpreter and should work without requiring any additional software. Windows has a packaged ...

    vmware workstation 11 unlock

    The python.exe file must be on the executable PATH. If it is not on PATH please edit win-install.cmd to point to the installation path. 3. Limitations -------------- The Unlocker currently does not...

    Python生成带照片的二维码、动图二维码,及识别二维码,Python二维码应用

    在本主题中,我们将深入探讨Python如何用于生成带有照片的二维码(QR code)、动图二维码,以及如何进行二维码的识别。这些技术在现代生活中的应用广泛,如营销推广、信息传递、物联网设备标识等。 首先,让我们...

    Python 2.4 Quick Reference Card

    ### Python 2.4 快速参考卡知识点详解 #### 一、环境变量与命令行选项 **环境变量** - **定义**: Python 运行时会读取一系列环境变量来配置其行为。 - **示例**: `PYTHONPATH` 用于指定额外的模块搜索路径。 **...

    vmware unlocker 2.0.3

    The code requires Python 2.7 to work. Most Linux distros and OS X ship with a compatible Python interpreter and should work without requiring any additional software. Windows has a packaged version ...

    The IDA Pro Book

    Extend IDA to support new processors and filetypes using the SDK * Explore popular plug-ins that make writing IDA scripts easier, allow collaborative reverse engineering, and much more * Use IDA's ...

Global site tag (gtag.js) - Google Analytics