docker中pip install/uninstall报错
程序员文章站
2022-07-14 13:17:57
...
docker中pip install or uninstall报错
事件起因
今天开发同学咨询了一个问题,他说在docker的一个运行容器中执行如下命令:
- cd /usr/lib/python2.7/site-packages/ 该目录下有两个目录,分别是:smart_open 和 samrt_open-1.5.5-py2.7.egg-info
- rm -rf samrt_open-1.5.5-py2.7.egg-info/ 这时出现报错,报错信息如下:
rm: cannot remove 'smart_open-1.5.5-py2.7.egg-info/': Directory not empty
- 通过命令ls -l查看该目录下的文件时出现如下错误信息:
ls: cannot access PKG-INFO: No such file or directory
ls: cannot access SOURCES.txt: No such file or directory
ls: cannot access dependency_links.txt: No such file or directory
ls: cannot access installed-files.txt: No such file or directory
ls: cannot access requires.txt: No such file or directory
ls: cannot access top_level.txt: No such file or directory
?????????????? ? ? ? ? ? PKG-INFO
?????????????? ? ? ? ? ? SOURCES.txt
?????????????? ? ? ? ? ? dependency_links.txt
?????????????? ? ? ? ? ? installed-files.txt
?????????????? ? ? ? ? ? requires.txt
?????????????? ? ? ? ? ? top_level.txt
- 卸载 smart_open: pip uninstall smart_open 出现如下报错信息:
...
OSError: [Errno 39] Directory not empty: "/usr/lib/python2.7/site-packages/smart_open-1.5.5-py2.7.egg-info"
分析原因
- 查看 docker 的存储驱动
# docker info
Containers: 80
Running: 37
Paused: 0
Stopped: 43
Images: 1342
Server Version: 17.09.0-ce
Storage Driver: overlay
Backing Filesystem: extfs
Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
- 根据开发同学反馈,相同的docker镜像,在MAC本上是没有该问题出现的,查看下MAC本的docker存储驱动
docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 19
Server Version: 17.09.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
- 发现linux上docker存储驱动是overlay,而Mac本的存储驱动是overlay2。
比较以上信息,出现本次问题的原因可能是:该问题在docker的overlay存储驱动下可能出现该问题,原因可能是因为overlay存储层并非是完全的隔离,在容器层卸载相关包的时候会导致镜像层的内容无法进行写操作。
处理方式
强制重新安装包
pip install [包名] --ignore-installed [包名]
转载于:https://blog.51cto.com/wutengfei/2161960
上一篇: Apache Flink(五):Flink Operator
下一篇: Timer定时器
推荐阅读
-
在centos7 中docker info报错docker bridge-nf-call-iptables is disabled 的解决方法
-
pip install browsercookie报错问题
-
Pycharm下载pyinstaller报错:You should consider upgrading via the 'python -m pip install --upgrade pip' command的解决方法
-
Pycharm下载pyinstaller报错:You should consider upgrading via the 'python -m pip install --upgrade pip' command的解决方法
-
解决pip install的时候报错timed out的问题
-
Python-pip3 install turtle报错ERROR: Command errored out with exit status 和setup.py-except ValueErro
-
windows终端输入pip install requests报错:Fatal error in launcher
-
python搭建环境:pip install -r requirements/base.txt时安装mysqlclient报错
-
pip install mysqlclient 报错 OSError: mysql_config not found
-
python安装exe打包库命令pip install pyinstaller报错,使用pip国内镜像解决方法