淘先锋技术网

首页 1 2 3 4 5 6 7

以下内容为带着儿子一起学Python的实现记录,为自己保存下来,也希望对其他学习者有用!

1. 确保已经安装python,本例使用python,操作系统为:Windows 10 专业版;

2. 设置环境变量,设置两个path路径。

E:\Python27 和E:\Python27\Scripts(为安装时选择的路径)

3. 查看Python以及pip安装成功

3.1 查看Python,开始菜单->输入cmd->输入python,正常显示如下图:

3.2查看pip,在步骤3.1中按Ctrl+C退出python,输入pip,正常显示如下图:

4. 安装pyttsx,在命令行输入pip install pyttsx,安装完成如下图:

python3,在命令行输入pip3install pyttsx3

5. 安装pywin32,

Step 2: Installing pywin32

The pyttsx library/package has a dependence of pywin32,so you need to install this package also. In this using pip is not a good ideaand most circumstances the installation will fail. So the best method isinstall pywin32 is by downloading the .exe file from the pywin32 Source Forge website.(老的版本:)

New downloadscan now be found at https://github.com/mhammond/pywin32/releases All buildsfrom Build 222 and later can be found *only* on github.(新版本)

选择好对应的版本,我安装的py2.4-amd64,因此,选择红框中的版本进行安装。

官方说明:

To downloadpywin32 binaries you must choose both the correct Python version and"bittedness".

Note that thereis one download package for each supported version of Python - please checkwhat version of Python you have installed and download the correspondingpackage.

Some packageshave a 32bit and a 64bit version available - you must download the one whichcorresponds to the Python you have installed. Even if you have a 64bitcomputer, if you installed a 32bit version of Python you must install the 32bitversion of pywin32.

To determinewhat version of Python you have, just start Python and look at the first lineof the banner. A 32bit build will look something like

Python2.7.2+ ... [MSC v.1500 32 bit (Intel)] on win32

While a 64bitbuild will look something like:

Python2.7.2+ ... [MSC v.1500 64 bit (AMD64)] on win32

我电脑查看出来的结果:

4.1 出错解决

安装时,出现如下错误:

closefailed in file object destructor:sys.excepthook is missing lost sys.stderr

(1)右键管理员身份运行cmd命令提示符:

(2)切换到E:\Python27\Scripts文件夹下,命令为:cdE:\Python27\Scripts

最上面的小红框告诉我们当前处于管理员模式命令提示符

(3)运行python pywin32_postinstall.py -install

(4)退出命令行

参考: