zoukankan      html  css  js  c++  java
  • 树莓派ZeroW 安装软件工具(数据远程采集)--Python3

    >> [目录] 数据远程采集 Step by Step


    树莓派型号:Zero W

    树莓派系统:Raspbian,2018-11-13-raspbian-stretch-lite.img

    Python版本:3.5.3

    待安装软件工具:

    pip3Python 包管理工具,提供了对Python 包的查找、下载、安装、卸载的功能
    pyserial Python的串口通讯包
    python3-psutil Process and System Utilities。访问系统CPU,内存,磁盘,网络等;进程管理(判断进程是否存在、获取进程列表、获取进程详细信息);命令行工具的功能(ps,top,lsof,netstat,ifconfig, who,df,kill,free,nice,ionice,iostat,iotop,uptime,pidof,tty,taskset,pmap)
    ntp Network Time Protocol。提供时间同步服务
    oss2 阿里云对象存储(oss)的Python工具包



    电脑和树莓派连接同一个无线网络,使用PuTTY登录SSH(Host Name:raspberrypi.local,Port:22,点击Open)。


    image_thumb


    输入用户名(默认:pi)和密码(默认:raspberry)

    image_thumb21


    查看Python版本


    pi@raspberrypi:~ $ python3 --version

    image


    安装pip3


    查看有没有安装pip3,显示pip3还没有装

    pi@raspberrypi:~ $ pip3 --version

    image


    下载安装脚本get-pip.py

    pi@raspberrypi:~ $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

    image_thumb3


    运行安装脚本get-pip.py

    pi@raspberrypi:~ $ sudo python3 get-pip.py

    上面默认是从国外的服务器下载相关软件包的,我们最好指定一个国内的软件包镜像源,下载速度会快很多。

    pi@raspberrypi:~ $ sudo python3 get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple

    显示这个脚本下载安装了pip-20.0.2, setuptools-46.1.3, wheel-0.34.2这三个软件工具(部分工具与python2的共用,我之前已经装过了,不再安装)。

    image

    查看pip3版本,显示正常,表示pip3已经安装成功

    pi@raspberrypi:~ $ pip3 --version

    image


    安装pyserial


    用pip3工具安装pyserial,指定国内的镜像源:

    pi@raspberrypi:~ $ sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pyserial

    image

    安装oss2


    用pip3工具安装oss2,指定国内的镜像源:

    pi@raspberrypi:~ $ sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple oss2

    image

    image


    安装python3-psutil

    需要用到aptitude来安装python3-psutil,这个工具在装系统的时候已经自动安装上了。

    如果没装的话先安装:

    pi@raspberrypi:~ $ sudo apt-get install aptitude

    查看aptitude的版本:

    pi@raspberrypi:~ $ aptitude --version

    image_thumb10

    安装python3-psutil

    pi@raspberrypi:~ $ sudo aptitude install python3-psutil

    image


    安装ntp


    存储数据帧时需要加上时间戳,ntp服务可以让树莓派与网络时间保持同步。

    pi@raspberrypi:~ $ sudo apt-get install ntp

    image_thumb12

    选择Y

    image_thumb13

    pi@raspberrypi:~ $ sudo apt-get install ntpdate

    image_thumb14

    查看当前时间,可以看到默认采用英国时间(BST, British Summer Time)

    pi@raspberrypi:~ $ date

    image_thumb15

    配置时区

    pi@raspberrypi:~ $ sudo dpkg-reconfigure tzdata

    在弹出的配置窗口中选择Asia,回车

    image_thumb16

    在下一页窗口中,选择Shanghai(按 S 键可以快速定位到S开头的城市),回车确认

    image_thumb17

    显示配置结果,时间已经正常了

    image_thumb18

    编辑ntp.conf文件

    pi@raspberrypi:~ $ sudo nano /etc/ntp.conf

    在这两句的后面增加增加国内的ntp服务器地址,保存退出

    # You do need to talk to an NTP server or two (or three).
    #server ntp.your-provider.example

    server ntp.fudan.edu.cn iburst perfer
    server time.asia.apple.com iburst
    server asia.pool.ntp.org iburst
    server ntp.nict.jp iburst
    server time.nist.gov iburst

    image_thumb19

    重启ntp服务,并查看时间

    pi@raspberrypi:~ $ sudo /etc/init.d/ntp restart

    pi@raspberrypi:~ $ date

    image_thumb20

  • 相关阅读:
    Chrome 过滤广告插件暂替办法
    IE8.1将支持Firefox插件,Gecko和Webkit引擎
    Adobe与Facebook联手推出Flash开发工具
    Google Chrome Greasemetal
    vmware虚机下的linux集群
    新版Safari浏览器胜在速度
    Fedora 11 Beta发布
    Sun宣布本周裁员1500人 或为IBM收购做准备
    Opera Mobile9.7将支持Flash Lite和Google Gears
    Red Hat CEO:桌面Linux无用
  • 原文地址:https://www.cnblogs.com/hotwater99/p/12739042.html
Copyright © 2011-2022 走看看