当前位置:   article > 正文

python 安装serial模块_python安装serial模块

python安装serial模块

如果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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

2,在linux系统上安装pyserial
1,首先先下载软件包
https://pypi.org/project/pyserial/ —下载的地址
在这里插入图片描述

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$
  • 1
  • 2
  • 3

在进入到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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

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).
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/180790?site
推荐阅读
相关标签
  

闽ICP备14008679号