Python开发环境搭建

1、软件准备

cx_Freeze-4.3.win32-py3.2.msi   --打包用

PySide-1.2.2.win32-py3.2.exe    --跨平台用,QT

python-3.2.4.msi  --解析器

pywin32-217.win32-py3.2.exe --支持win32平台

2、遇到问题

Python执行exe程序时出现报错,因为cmd为utf-8,而python要求unicode,所以要先切换回unicode,我这里试了下:

切换cmd到中文编码格式:chcp 936

活动代码页: 936

C:\Users\tao>G:\Svn\Tool\Python\Hello\build\exe.win32-3.2\hello.exe
系统找不到指定的路径。

C:\Users\tao>G:\Svn\Tool\Python\Hello\build\exe.win32-3.2\hello.exe
hello

C:\Users\tao>G:\Svn\Tool\Python\Hello\build\exe.win32-3.2\hello.exe
hello

C:\Users\tao>z

  

还有cmd 命令行执行Python时出现问题:

报错,后面新增环境变量:

PYTHONIOENCODING

utf-8

运行python就OK了;

不能删除,应该是python运行时要切换到utf-8

后面这步可以删除,但是cmd的编码方式统一改成:

cmd默认的编码是采用GBK

regedit

HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe\CodePage
十进制:936 GBK

 

基本就这些了,需要注意的;

例子代码:--测试用

hello.py

import datetime
import sys
print ("hello")

setup.py

# A very simple setup script to create a single executable
#
# hello.py is a very simple "Hello, world" type script which also displays the
# environment in which the script runs
#
# Run the build process by running the command 'python setup.py build'
#
# If everything works well you should find a subdirectory in the build
# subdirectory that contains the files needed to run the script without Python

from cx_Freeze import setup, Executable

setup(
        name = "hello",
        version = "0.1",
        description = "Sample cx_Freeze script",
        executables = [Executable("hello.py")])

  

打包批处理:command.bat

python setup.py build

pause
continue

  

 

转载于:https://www.cnblogs.com/tao560532/p/4779858.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值