热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

python安装serial模块

如果python想要操作串口,需要首先先安装pyserial,在不同的系统上安装pythonserial模块的方法不一样,在windowns系统上,你可以直接直接通过pipinst

如果python想要操作串口,需要首先先安装pyserial,
在不同的系统上安装python serial模块的方法不一样,
在windowns系统上,你可以直接直接通过pip install pyserial去安装pyserial,但是在linux系统上你需要把
pyserial的源码包下载下来,解压,然后执行安装命令。

1,在windows系统上的操作:


C:\Users\test>pip install pyserial
Collecting pyserial
Downloading https://files.pythonhosted.org/packages/0d/e4/2a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30/pyserial-3.4-py2.py3-none-any.whl (193kB)
100% |████████████████████████████████| 194kB 885kB/s
Installing collected packages: pyserial
**Successfully installed pyserial-3.4**
You are using pip version 19.0.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\test>

2,在linux系统上安装pyserial
1,首先先下载软件包
https://pypi.org/project/pyserial/ —下载的地址
《python 安装serial模块》

2,在linux系统上安装pyserial

在linux系统上安装又两种方式,一中和windows上一样,另一种就是通过软件包去安装。
如果linux上没有安装pip,需要通过sudo apt install python-pip去安装pip工具。

(1), tar xvf pyserial-3.4.tar.gz
(2), cd pyserial-3.4
(3), sudo python setup.py install

软件包里面包含的文档:
documentation, examples都是可以借鉴学习的好资料。

1
~/Software/pyserial-3.4$ ls
build CHANGES.rst **documentation** **examples** LICENSE.txt MANIFEST.in PKG-INFO pylintrc pyserial.egg-info **README.rst** serial setup.cfg setup.py test
~/Software/pyserial-3.4$

在进入到pyserial-3.4之后,可以先去查看一下README.rst,这个里面有很多有
用的信息,对于安装可以参考https://github.com/pyserial/pyserial/blob/master/documentation/pyserial.rst#installation,使用样例可以参考https://github.com/pyserial/pyserial/tree/master/examples.

1,
=================================
pySerial |build-status| |docs|
=================================
Overview
========
This module encapsulates the access for the serial port. It provides backends
for Python_ running on Windows, OSX, Linux, BSD (possibly any POSIX compliant
system) and IronPython. The module named "serial" automatically selects the
appropriate backend.
- Project Homepage: https://github.com/pyserial/pyserial
- Download Page: https://pypi.python.org/pypi/pyserial
BSD license, (C) 2001-2017 Chris Liechti <cliechti@gmx.net>
Documentation
=============
For API documentation, usage and examples see files in the "documentation"
directory. The ".rst" files can be read in any text editor or being converted to
HTML or PDF using Sphinx_. An HTML version is online at
https://pythonhosted.org/pyserial/
Examples
========
Examples and unit tests are in the directory examples_.
Installation
============
``pip install pyserial`` should work for most users. Detailed information can be found in `documentation/pyserial.rst`_. The usual setup.py for Python_ libraries is used for the source distribution. Windows installers are also available (see download link above). .. _`documentation/pyserial.rst`: https://github.com/pyserial/pyserial/blob/master/documentation/pyserial.rst#installation
.. _examples: https://github.com/pyserial/pyserial/blob/master/examples
.. _Python: http://python.org/
.. _Sphinx: http://sphinx-doc.org/
.. |build-status| image:: https://travis-ci.org/pyserial/pyserial.svg?branch=master
:target: https://travis-ci.org/pyserial/pyserial
:alt: Build status
.. |docs| image:: https://readthedocs.org/projects/pyserial/badge/?version=latest
:target: http://pyserial.readthedocs.io/
:alt: Documentation

part of link https://github.com/pyserial/pyserial/blob/master/documentation/pyserial.rst#installation

Installation**加粗样式**
This installs a package that can be used from Python (import serial).
To install for all users on the system, administrator rights (root) may be required.
From PyPI
pySerial can be installed from PyPI:
python -m pip install pyserial
Using the python/python3 executable of the desired version (2.7/3.x).
Developers also may be interested to get the source archive, because it contains examples, tests and the this documentation.
From Conda
pySerial can be installed from Conda:
conda install pyserial
or
conda install -c conda-forge pyserial
Currently the default conda channel will provide version 3.4 whereas the conda-forge channel provides the current 3.x version.
Conda: https://www.continuum.io/downloads
From source (zip/tar.gz or checkout)
Download the archive from http://pypi.python.org/pypi/pyserial or https://github.com/pyserial/pyserial/releases. Unpack the archive, enter the pyserial-x.y directory and run:
python setup.py install
Using the python/python3 executable of the desired version (2.7/3.x).

推荐阅读
author-avatar
ChiuChiuLIN
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有