# Raspberry_Pi **Repository Path**: Robot_LI/Raspberry_Pi ## Basic Information - **Project Name**: Raspberry_Pi - **Description**: 树莓派熟悉笔记 - **Primary Language**: Python - **License**: CC-BY-SA-4.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-08-05 - **Last Updated**: 2024-07-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Raspberry_Pi**RaspberryPi4入门教程** 1 ## 零. 树莓派真香! ### 0.1 what is Raspberry Pi? ​ 树莓派(英语:Raspberry Pi)是基于Linux的单片机电脑,由英国树莓派基金会开发,目的是以低价硬件及自由软件促进学校的基本计算机科学教育。你可以把它理解为一台卡片电脑(可以跑linux操作系统) ​ [官方网址](https://www.raspberrypi.org/):https://www.raspberrypi.org/ ​ 这一代的树莓派性能有很大的提升,支持双4K Micro Hdmi视频输出,千兆有限网口,内存可选(1~4G),电源接口也与时俱进改为Type-C 等等...... 2 ### 0.2 linux系统 ​ 有同学可能会问,啥是linux操作系统? 这个请自行百科。我的理解是如果苹果手机的ios系统就好比PC上的windows系统,那么安卓手机上的Android系统就好比是PC上的linux系统。(初学者一般建议使用官方推荐的Raspbian操作系统,里面内置了很多学习使用的编程软件Scratch、Thonny、Node-RED、mu等等) 树莓派支持很多三方系统: 3 官方系统下载地址:https://www.raspberrypi.org/downloads/ ### 0.3 树莓派能做什么? ## 一. 入门准备工作 ### 1.1硬件准备 | 器材名称 | 数量 | 器材名称 | 数量 | | :----------------------: | :--: | :----------------------: | :--: | | 树莓派4B | 1 | 树莓派电源(typeC) | 1 | | 32G-MircoSD内存卡&读卡器 | 1 | USB鼠标&键盘套装 | 1 | | 笔记本电脑 | 1 | 显示器或电视(可选) | 1 | | 网线(可选) | 1 | 树莓派专用摄像头(可选) | 1 | 建议淘宝直接购买套装即可 ### 1.2软件工具准备 | 软件名称 | 作用 | 软件名称 | 作用 | | :---------------: | :----------------: | :----------: | :------------------------------: | | SD Card Formatter | 格式化SD卡工具 | balenaEtcher | 树莓派系统烧录工具 | | Win32DiskImager | 树莓派系统备份工具 | WinSCP | 树莓派与PC文件传输工具 | | putty | ssh连接工具 | VNC | 树莓派与PC远程图形化界面连接工具 | | raspbian-buster | 树莓派操作系统文件 | SSH文档 | 首次配置树莓派wifi | 软件工具下载地址:https://pan.baidu.com/s/17ZWxyoSTJHXt0-I7iSwcbQ 提取码:5fpl 4 ### 1.3具体配置流程 ![5](https://gitee.com/Robot_LI/Raspberry_Pi/raw/master/Images/5.png "在这里输入图片标题") ------ ## 二.配置步骤 ### 2.1 格式化SD卡,准备烧录系统 1. 准备一张32G的Mirco-SD卡(推荐闪迪),和一个USB3.0的读卡器(烧录速度可以更快一些,减少等待时间,前提是你的PC也是支持USB3.0接口)。![6](https://gitee.com/Robot_LI/Raspberry_Pi/raw/master/Images/6.png "在这里输入图片标题") 2. 把SD卡插入读卡器让后通过USB接口连接PC。![7](https://gitee.com/Robot_LI/Raspberry_Pi/raw/master/Images/7.png "在这里输入图片标题") 3. 使用SD Card Formatter工具格式化这张SD卡(无论SD卡是否新旧或是否已经使用,请注意格式化后卡内所有资料将清空) ![8](https://gitee.com/Robot_LI/Raspberry_Pi/raw/master/Images/8.png "在这里输入图片标题") ------ ### 2.2 烧录&安装树莓派系统 1. ​ 打开balenaEtcher软件,烧录Raspbian系统到SD卡 9 如果有弹窗跳出,请点击确认继续....... 10 2. 完成烧录前,不要点击弹出的格式化弹窗(或点击取消即可)。 11 3. 提示格式化(点击取消),最后直到完成烧录(Falsh Complete)。 12 4.直接桌面右下角弹出sd卡即可。 ![13](https://gitee.com/Robot_LI/Raspberry_Pi/raw/master/Images/13.png "在这里输入图片标题") ### 2.3 首次登陆 1.把SD卡插入树莓派的卡槽,然后接通电源即可开机。首次开机建议连接显示器、插入USB鼠标和键盘 ### 远程控制 VNCZ文件管理对话框闪退 ``` sudo apt-get install --reinstall pcmanfm ``` 更换更内源 ``` sudo nano /etc/apt/sources.list ``` #清华大学 deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi #中国科学技术大学 deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contribnon-free rpi #阿里云 deb http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi deb-src http://mirrors.aliyun.com/raspbian/raspbian/ buster main contrib non-free rpi #华中科技大学 deb http://mirrors.hustunique.com/raspbian/raspbian/ buster main contrib non-free rpi deb-src http://mirrors.hustunique.com/raspbian/raspbian/ buster main contrib non-free rpi 给`Python`的第三方模块安装工具`pip`换源 在树莓派的命令行中依次输入运行以下三个命令 ``` sudo mkdir ~/.pip cd .pip sudo nano pip.conf ``` 在打开的文件中输入以下内容: ``` [global] timeout = 10 index-url = http://mirrors.aliyun.com/pypi/simple/ extra-index-url= http://pypi.douban.com/simple/ [install] trusted-host= mirrors.aliyun.com pypi.douban.com ``` pip国内的镜像 1.   #阿里云 http://mirrors.aliyun.com/pypi/simple/ 2.   #中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 3.   #豆瓣(douban) http://pypi.douban.com/simple/ 4.   #清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 5.   #中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/ ## **修改源方法** **临时使用:** 可以在使用pip的时候在后面加上-i参数,指定pip源 1. pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple 安装中文字体及输入法 ``` sudo apt-get install fonts-wqy-zenhei ``` 安装中文输入法fcitx及Google拼音输入法 ``` sudo apt-get install fcitx fcitx-googlepinyin fcitx-module-cloudpinyin fcitx-sunpinyin ``` 安装远程桌面登陆软件teamviewer ``` wget http://download.teamviewer.com/download/linux/version_11x/teamviewer-host_armhf.deb sudo dpkg -i teamviewer-host_armhf.deb sudo apt-get -f install sudo apt-get install gdebi sudo gdebi teamviewer-host_armhf.deb ``` > wget https://tv-static-net.oss-cn-beijing.aliyuncs.com/download/tv14/linux/teamviewer-host_14.2.8352_armhf.deb > > sudo dpkg -i teamviewer-host_14.2.8352_armhf.deb > > sudo apt-get -f install python虚拟环境配置: 安装虚拟环境命令:sudo apt-get install python3-venv 构建一个新的虚拟环境:python3 -m vnen [虚拟环境名字] 例如:python3 -m venv OpenCV_env 激活虚拟环境:source OpenCV_env/bin/activate 安装基础包:pip install wheel 退出虚拟环境:deactivate 运行虚拟环境中的程序:虚拟环境名称/bin/python 程序名 例如:OpenCV_env/bin/python abc.py Opencv 安装: 1.Dlib人脸探测配置说明文档 https://www.home-assistant.io/components/image_processing.dlib_face_detect/ 安装dlib前准备必要的库,apt-get安装命令:sudo apt-get install libatlas-base-dev cmake 进入python虚拟环境安装: 1. 安装dlib: pip install dlib 2. 安装opencv :pip install opencv-python http://pypi.douban.com/simple/