在 python 3.4 windows 8.1 中安装和使用 pyserial
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27596776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
installing and using pyserial in python 3.4 windows 8.1
提问by Jose Fernando Gomez Davila
I want to use pyserial but I do not know what I am doing wrong
我想使用 pyserial 但我不知道我做错了什么
I have installed python 3.4.2 from this link www-python-org-downloads-release-python-342- the one that says "Windows x86-64 MSI installer" and I got this archive "python-3.4.2.amd64.msi" because my operating system is 64 bit during the installation I have selected "add python.exe to path" (will be installed on local hard drive), and all the other ones
我已经从这个链接 www-python-org-downloads-release-python-342 安装了 python 3.4.2- 那个说“Windows x86-64 MSI 安装程序”的,我得到了这个档案“python-3.4.2.amd64。 msi”因为我的操作系统在安装过程中是 64 位我选择了“将 python.exe 添加到路径”(将安装在本地硬盘上),以及所有其他的
I went to the pyserial website http://pyserial.sourceforge.net/pyserial.html#installationwhich say "Download the archive from http://pypi.python.org/pypi/pyserial. Unpack the archive, enter the pyserial-x.y directory and run:" and sent me to this link http-pypi-python-org-pypi-pyserial
我去了 pyserial 网站http://pyserial.sourceforge.net/pyserial.html#installation,上面写着“从http://pypi.python.org/pypi/pyserial下载存档。解压存档,输入 pyserial- xy 目录并运行:”并将我发送到此链接 http-pypi-python-org-pypi-pyserial
I have donwloaded from this link, these three archives pyserial-2.7.tar.gz, pyserial-2.7.win32.exe pyserial-2.7.win32_py3k.exe
我从这个链接下载了这三个存档 pyserial-2.7.tar.gz, pyserial-2.7.win32.exe pyserial-2.7.win32_py3k.exe
I have tried to run the .exe one but they say "No python installation found in the registry", which I dont know why
我试图运行 .exe 一个,但他们说“在注册表中没有找到 python 安装”,我不知道为什么
then I unpack the .gz file with Winrar enter into the folder and try to run "pyserial-x.y" but there is nothing like that in this folder in this folder I can find
然后我用 Winrar 解压 .gz 文件进入文件夹并尝试运行“pyserial-xy”但在这个文件夹中的这个文件夹中没有类似的东西我可以找到
documentation (folder)
examples
serial
test
CHANGES.txt
LICENSE.txt
MANIFEST.in
PKG-INFO
README.txt
setup.py
I tried to run this "setup.py" but for a second a black window appears
我试图运行这个“setup.py”,但有一秒钟出现了一个黑色窗口
detected Python 3, using 2to3
C;\Python34\lib\distutils\dist.py:260: UserWarning: Unknow distribution option: use_2to3
warning.warn(msg)
usage: setup.py [global_opts] [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help commands
or: setup.py cmd --help
error: no commands supplied
and then disappears
然后消失
I went to the command prompt and wrote "python3 setup.py install" or python setup.py install but it says Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\Users\me>python3 setup.py install 'python3' is not recognized as an internal or external command operable program or batch file.
我去了命令提示符并写了“python3 setup.py install”或python setup.py install,但它说Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation。版权所有。C:\Users\me>python3 setup.py install 'python3' 不是内部或外部命令可操作的程序或批处理文件。
so I cant do that either
所以我也不能那样做
then in command prompt I chancge the directory with "cd C:\Users\me\Downloads\pyserial-2.7" which is the place where the folder .gz is then "python setup.py install" and "python3 setup.py install" but they do not work there is the code and at the end it says
然后在命令提示符下,我用“cd C:\Users\me\Downloads\pyserial-2.7”更改目录,这是文件夹.gz的位置,然后是“python setup.py install”和“python3 setup.py install”但它们不起作用,有代码,最后它说
C:\Users\me\Downloads\pyserial-2.7>python setup.py install
Detected Python 3, using 2to3
C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option:
'use_2to3'
warnings.warn(msg)
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
running install_egg_info
Removing C:\Python34\Lib\site-packages\pyserial-2.7-py3.4.egg-info
Writing C:\Python34\Lib\site-packages\pyserial-2.7-py3.4.egg-info
C:\Users\me\Downloads\pyserial-2.7>
then I try to write in the command prompt "python" then "import serial" but still it does not work
然后我尝试在命令提示符“python”然后“import serial”中写入但仍然不起作用
THEN i DO NOT KNOW WHAT TO DO
然后我不知道该怎么办
could somebody help me
有人可以帮我吗
采纳答案by Jose Fernando Gomez Davila
well actually it is working, the last part of my question "last code" says that the installation was successful
好吧,实际上它正在工作,我的问题“最后一段代码”的最后一部分说安装成功
sorry to bother
抱歉打扰
so in order to clarify this issue I will write the whole process, Please recommend this post to all the people who is having the same issue, IT WAS SO ANNOYING without A CLEAR PROCESS
所以为了澄清这个问题,我会写下整个过程,请把这篇文章推荐给所有遇到同样问题的人,没有一个清晰的过程就太烦人了
- first download Python 3.4.2, install it
- then download pyserial "pyserial-2.7.tar.gz"
- unzip with Winrar
- go to command prompt
- change the directory means write "cd C:\Users\me\Downloads\pyserial-2.7>" which is the inside of the unzipped folder, or wherever you unzipped the pyserial.gz
- then write "python setup.py install"
- in the installation process activate the last option, use in the local disk
- 首先下载Python 3.4.2,安装
- 然后下载pyserial“pyserial-2.7.tar.gz”
- 用Winrar解压
- 转到命令提示符
- 更改目录意味着写“cd C:\Users\me\Downloads\pyserial-2.7>”,这是解压文件夹的内部,或者你解压pyserial.gz的任何地方
- 然后写“python setup.py install”
- 在安装过程中激活最后一个选项,在本地磁盘中使用
done
完毕
回答by Burhan Khalid
As there are multiple issues with your installation, I recommend you start fresh by do the following:
由于您的安装存在多个问题,我建议您通过执行以下操作重新开始:
- Uninstall the 64bit version of Python, reboot your computer.
- Download and install the 32bit MSI installer from python.org
- 卸载 64 位版本的 Python,重新启动计算机。
- 从 python.org 下载并安装 32 位 MSI 安装程序
A lot of libraries are already compatible with Python 3, but not everything is there yet and you don't want to run into issues during development; so I would recommend the latest 2.7.x version.
许多库已经与 Python 3 兼容,但并不是所有的东西都已经存在,你不希望在开发过程中遇到问题;所以我会推荐最新的 2.7.x 版本。
- Download and install the setuptools package.
- Download the file
pyserial-2.7.win32.exe
and then double click it to run.
- 下载并安装setuptools 包。
- 下载文件
pyserial-2.7.win32.exe
,然后双击它运行。