树莓派python库配置/安装/更新

在线


在树莓派网络配置好的情况下
如何确定网络是配置好的,可以看在桌面的wifi图标有没有显示连接上了,如果连接上了会显示在网络中的ip地址

ping www.baidu.com
ping dns_ip

需提前配置好镜像源,

树莓派软件源配置

树莓派基金会单独(非Raspbian开发者)提供/维护的软件源,主要包括raspi-config、minecraftpi、树莓派桌面环境、内核固件驱动等少量软件。
这个软件源相关资料比较少,国内目前只有清华(201709开始提供)和中科大有提供


#### Stretch(选择清华的源就行)
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
deb-src  url # 如上相同
# 'deb-src'默认将软件源码一并下载至树莓派
# 'deb-src'不加也可以  
#### Jessie
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ jessie main ui

配置/etc/apt/sources.list里的软件源

raspbian这个源是由独立开发者维护的,与树莓派基金会并无直接联系。国内源比较多,选择一个与自己延迟最小或连接速度最好或物理距离最短的即可。

#Stretch
deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

#Jessie
deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi

也可使用

    # 中科大
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi 
    # 清华
deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    #  大连东软
deb http://mirrors.neusoft.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    # 重庆大学
deb http://mirrors.cqu.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    # 浙江大学
deb http://mirrors.zju.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    # 阿里云
deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi 
    # 搜狐
deb http://mirrors.sohu.com/raspbian/raspbian/ stretch main contrib non-free rpi 
    # 元智大学(中国台湾)
deb http://ftp.cse.yzu.edu.tw/Linux/raspbian/raspbian/ stretch main contrib non-free rpi 
    # 新加坡国立大学
deb http://mirror.nus.edu.sg/raspbian/raspbian/ stretch main contrib non-free rpi
    # 北陆先端科学技术大学院大学(日本知名镜像站,日常出口带宽2g)
deb http://ftp.jaist.ac.jp/raspbian/ stretch main contrib non-free rpi
    # 牛津大学
deb http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian/  stretch main contrib non-free rpi
    # 美国Berkely大学
deb http://mirrors.ocf.berkeley.edu/raspbian/raspbian/ stretch main contrib non-free rpi
    # 美国俄克拉荷马大学
deb http://reflection.oss.ou.edu/raspbian/raspbian/ stretch main contrib non-free rpi
    # 南非知名软件源
deb http://mirror.liquidtelecom.com/raspbian/raspbian/ stretch main contrib non-free rpi 
    # 默认源(带重定向by mirrorbrain)
deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi
    # 官方源
deb https://archive.raspbian.org/raspbian/ stretch main contrib non-free rpi

配置/etc/pip.conf的pypi镜像源

国内源:

新版ubuntu要求使用https源,要注意

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/ 

豆瓣:http://pypi.douban.com/simple/

[global]

extra-index-url=http://mirrors.aliyun.com/pypi/simple

[install]

trusted-host=mirrors.aliyun.com

sudo pip install package<=1.2.0 # 可规定版本

sudo pip install package -i url

sudo python -m pip install package


临时使用:

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider # 这样就会从清华这边的镜像去安装pyspider库


离线

首先通过另外一台可以联网的电脑下载库文件

下载地址可以去:

http://pypi.org/

# 各种大学企业的镜像源

https://pypi.tuna.tsinghua.edu.cn/simple

https://pypi.tuna.tsinghua.edu.cn/simple

https://mirrors.aliyun.com/pypi/simple/

https://pypi.mirrors.ustc.edu.cn/simple/

https://pypi.hustunique.com/

https://pypi.sdutlinux.org/ 

https://pypi.douban.com/simple/

选择下载download,选择文件类型source,就是以.tar.gz,.tar.xz后缀的文件。
解压至树莓派

cd package_path # 访问文件路径
sudo python setup.py install # 即可安装

如果是.whl文件

cd package_path # 访问文件路径
sudo pip install package.whl

想要安装到python3,把上示例代码的python或pip分别改成python3或pip3即可

猜你喜欢

转载自www.cnblogs.com/NoLoss/p/11963211.html