热门标签 | 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).

推荐阅读
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 本文详细探讨了Java中的24种设计模式及其应用,并介绍了七大面向对象设计原则。通过创建型、结构型和行为型模式的分类,帮助开发者更好地理解和应用这些模式,提升代码质量和可维护性。 ... [详细]
  • 本文介绍了在安装或运行 Python 项目时遇到的 'ModuleNotFoundError: No module named setuptools_rust' 错误,并提供了解决方案。 ... [详细]
  • 本文详细介绍了如何使用Python编写爬虫程序,从豆瓣电影Top250页面抓取电影信息。文章涵盖了从基础的网页请求到处理反爬虫机制,再到多页数据抓取的全过程,并提供了完整的代码示例。 ... [详细]
  • 探讨一个显示数字的故障计算器,它支持两种操作:将当前数字乘以2或减去1。本文将详细介绍如何用最少的操作次数将初始值X转换为目标值Y。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • 离线环境下的Python及其第三方库安装指南
    在项目开发中,有时会遇到电脑只能连接内网或完全无法联网的情况。本文将详细介绍如何在这种环境下安装Python及其所需的第三方库,确保开发工作的顺利进行。 ... [详细]
  • 本文探讨了如何在给定整数N的情况下,找到两个不同的整数a和b,使得它们的和最大,并且满足特定的数学条件。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • PyCharm下载与安装指南
    本文详细介绍如何从官方渠道下载并安装PyCharm集成开发环境(IDE),涵盖Windows、macOS和Linux系统,同时提供详细的安装步骤及配置建议。 ... [详细]
  • 深入理解Cookie与Session会话管理
    本文详细介绍了如何通过HTTP响应和请求处理浏览器的Cookie信息,以及如何创建、设置和管理Cookie。同时探讨了会话跟踪技术中的Session机制,解释其原理及应用场景。 ... [详细]
  • 在Python开发过程中,随着项目数量的增加,不同项目依赖于不同版本的库,容易引发依赖冲突。为了避免这些问题,并保持开发环境的整洁,可以使用Virtualenv和Virtualenvwrapper来创建和管理多个隔离的Python虚拟环境。 ... [详细]
  • Python入门:第一天准备与安装
    本文详细介绍了Python编程语言的基础知识和安装步骤,帮助初学者快速上手。涵盖Python的特点、应用场景以及Windows环境下Python和PyCharm的安装方法。 ... [详细]
  • 本文介绍如何使用 Python 的 xlrd 库读取 Excel 文件,并将其数据处理后存储到数据库中。通过实际案例,详细讲解了文件路径、合并单元格处理等常见问题。 ... [详细]
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社区 版权所有