docker中pip install/uninstall报错

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 [包名]

原文地址:http://blog.51cto.com/wutengfei/2161960

时间: 2024-08-12 09:52:28

docker中pip install/uninstall报错的相关文章

pip install flask-mongoengine报错

pip install flask-mongoengine报错 报错如下: Collecting pytz (from -r /srv/wms/engine/requirements.txt (line 5)) Downloading https://pypi.doubanio.com/packages/a3/7f/e7d1acbd433b929168a4fb4182a2ff3c33653717195a26c1de099ad1ef29/pytz-2017.3-py2.py3-none-any.w

pip install wechatpy报错

安装python 版WeChat sdk pip install wechatpy[cryptography] 报错 Found existing installation: six 1.4.1 DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that

Mac中 pip3 install mysqlclient 报错

主要错误提示如下: ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'clang' failed with exit status 1 ---------------------------------------- Failed building wheel for mysqlclient

pip install mysqlclient报错(OSError: mysql_config not found)

报错截图 一般情况是系统没有安装libmysqld-dev 执行 sudo apt install libmysqld-dev完成安装后再 pip install mysqlclient就可以了(系统环境Ubuntu18.04) 原文地址:https://www.cnblogs.com/IT-Crowd/p/11742384.html

python安装matplotlib:python -m pip install matplotlib报错

matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,建议执行python -m pip install -U pip setuptools进行升级. 接着键入python -m pip install matplotlib进行自动的安装,系统会自动下载安装包. 安装完成后,可以用python -m pip list查看本机的安装的所有模块,确保matplotlib已经安装成功. 如果你能看的上面的m

Windows下Python中pip安装Pillow报错总结(转载)

遇到的俩种错误1.ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting 问题原因未知,博主尝试了一下解决方案可以解决问题.博主PC  是 Pthon3.4.3-win32pip install --upgrade pip 在cmd中更新一下pip,然后发现出现了第二个问题,权限问题,给用户添加所有者权限后,再次执行 pip install Pillow  完美安装Pillow

pip install scrapy报错:error: Unable to find vcvarsall.bat解决方法

今天在使用pip install scrapy 命令安装Scrapy爬虫框架时,出现了很让人头疼的错误,错误截图如下: 在网上查找解决方法时,大致知道了问题的原因.是因为缺少C语言的编译环境,其中一种解决方法就是安装相对应版本的Visual Studio,但是安装VS本身就极其麻烦,所以这种方法是不推荐的.第二种方法就是下载已经编译好的安装包. 1. 下载.whl安装包 可以到下面这个网址中下载与python版本以及系统(32位或64位)相匹配的Twisted版本,比如我下载的就是Twisted

mac下pip install lxml报错

解决方法: brew install libxml2 xcode-select --install sudo pip install lxml -i http://pypi.v2ex.com/simple

ubuntu16.04 pip install scrapy 报错处理

Failed building wheel for Twisted inculde/site/python3.5/Twisted failed with error code 1 in tmp/pip-install-y4-0q..... sudo apt-get install build-essential libssl-dev libffi-dev python3.5-dev# 或者 sudo aptitude install python3.5-dev pip install scrap