树莓派 Docker安装运行后,E: Unable to locate package无法安装服务,解决方案-更换源+apt-cache search
问题描述:
刚pull下来,首次启动,打开python用 import 验证服务缺漏情况;
pygame安装出错,Docker太精简,文本编辑服务都没安装,vim nano gedit等都not found,各种服务都无法安装和更新,(opencv:arm32v7 )连pip都没安装;有一个容器(opencv:arm32v7 ) curl正常,有一个容器(debian-opencv2)git正常还能用git clone,说明网络正常;
Reading package lists... Done
Reading package lists 没有显示进度,直接从0跳到下一步;
接着E: Unable to locate package **** ,报错,无法安装
树莓派3B+为Debian系统,通过cat 查看源;
aaa@qq.com:/home/smart_car# sudo cat /etc/apt/sources.list
deb http://archive.raspbian.org/raspbian jessie main contrib non-free rpi firmware
dymat/opencv arm32v7 31ee70a04dd8 db0562db6c8a
dymat/opencv:arm32v7
因为无法下载安装服务,无法更新,无法编写源,源码安装vim失败;所以只好直接docker cp,从主机 复制 sources.list 到容器对应目录;
首先进入容器,备份sources.list:
cd /etc/apt/
sudo mv /etc/apt/sources.list sources.list.bak
主机执行docker cp:
docker cp /etc/apt/sources.list 31ee70a04dd8:/etc/apt/
容器再apt-get更新:因为此容器还不能执行sudo,所以直接执行
apt-get update
必须更新两遍后才能安装服务,否则还出错;
安装pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
安装PIL.Image 图片,vim 文本编辑,游戏框架 pygame:
pip install pillow vim pygame
pillow 安装成功,vim 和 pygame 失败;
先search再安装pygame:
apt-cache search pygame
apt-get install python-pygame
同样方法,安装vim:
apt-cache search vim
apt-get install vim
完美解决!
参考:
https://www.cnblogs.com/UFO-blogs/p/9001408.html
https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=33157
al42and/debian-opencv2 raspberrypi 0627f62e6b44
4acc99961df5 al42and/debian-opencv2:raspberrypi
docker cp /etc/apt/sources.list 4acc99961df5:/etc/apt/
list:正常显示进度
sudo apt-get upgrade 要更新两次才能正常,安装服务
因为很多测试程序都用到 cv模块,所以先解决OpenCV2.4的安装服务问题;
如果要安装python包,可以通过运行来搜索它是否在存储库中:
apt-cache search pygame
然后,您可以看到包(如果它们在存储库中)及其名称。输出apt-cache search pygame
是:
aaa@qq.com:/home# apt-cache search pygame
lightyears - single player real-time strategy game with steampunk sci-fi
psychopy - environment for creating psychology stimuli in Python
pyntor - flexible and componentized presentation program
python-pygame-sdl2 - reimplementation of the Pygame API using SDL2
python-pyglet - cross-platform windowing and multimedia library
python-soya-doc - high level 3D engine for Python
solarwolf - Collect the boxes and don't become mad
python-pygame - SDL bindings for games development in Python (Python 2)
python3-pgzero - Zero-boilerplate games programming framework based on Pygame (Python 3)
python3-pygame - SDL bindings for games development in Python (Python 3)
aaa@qq.com:/home# sudo apt-get install python-pygame
在此列表中,您可以选择包(此处:) python-pygame
并运行sudo apt-get install the-package-name
。
sudo apt-get install python-pygame
关依赖项的更多调试,请参阅使用pip安装pygame。
完美解决!
印象中之前可以import cv2 和cv的,再测试后就报错;
ImportError: No module named cv2
试过直接apt-cache search cv2或cv,看了安装包感觉不大靠谱,按老规矩:
apt-cache search python-opencv
sudo apt-get install python-opencv
完美解决!
参考链接:
https://askubuntu.com/questions/399824/how-to-install-pygame?noredirect=1&lq=1