Python|--pip|--报错:ERROR: Cannot uninstall numpy 1.26.4, RECORD file not found. Hint: The package was installed by debian.

前言


一个Python项目, 需要部署到docker容器中, 
此时正在执行构建镜像的命令
 "sudo docker build -t cogtif_data_service ."

但是需要用到Python库"cinrad"
# Dockerfile摘抄
RUN pip install --no-cache-dir -r requirements.txt



# requirements.txt 部分摘抄
altgraph==0.17.4
APScheduler==3.10.0
Cartopy==0.24.1
certifi==2024.12.14
charset-normalizer==3.4.1
cinrad==1.4
cinrad_data==0.1

报错信息



37.29 Downloading configobj-5.0.9-py2.py3-none-any.whl (35 kB)
37.35 Downloading donfig-0.8.1.post1-py3-none-any.whl (21 kB)
38.09 Building wheels for collected packages: cinrad, cinrad_data, PyYAML
38.09   Building wheel for cinrad (setup.py): started
44.44   Building wheel for cinrad (setup.py): finished with status 'done'
44.63   Created wheel for cinrad: filename=cinrad-1.4-py3-none-any.whl size=44366303 sha256=31f58fc2c9dea4ce76498c00469c708cee927dfd700513420657c4ffe797c270
44.63   Stored in directory: /tmp/pip-ephem-wheel-cache-uq5iuuom/wheels/9a/03/b6/f32ed2d3ce7b680a165dfe821afdf664887c958891df037b0d
44.64   Building wheel for cinrad_data (setup.py): started
52.28   Building wheel for cinrad_data (setup.py): finished with status 'done'
52.53   Created wheel for cinrad_data: filename=cinrad_data-0.1-py3-none-any.whl size=58530728 sha256=33bebbf91163f7526f8ea0f95af2d60d8ef3e3d935ce4b4e311409e03353d852
52.53   Stored in directory: /tmp/pip-ephem-wheel-cache-uq5iuuom/wheels/ba/71/5a/f3379701f63c558ab2e487cf4bba7bd505e9582d40d671b827
52.53   Building wheel for PyYAML (setup.py): started
53.02   Building wheel for PyYAML (setup.py): finished with status 'done'
53.02   Created wheel for PyYAML: filename=PyYAML-5.2-cp312-cp312-linux_x86_64.whl size=44224 sha256=7ac238af87af4ea2847b02eac0c0aa7d148b9d8fc2cfce7d5e0f8bffe21a128b
53.02   Stored in directory: /tmp/pip-ephem-wheel-cache-uq5iuuom/wheels/ce/ec/08/2d47cadc0aa3fe275937ec06a3b3c2a73a33749a21e3a402f3
53.03 Successfully built cinrad cinrad_data PyYAML
53.81 Installing collected packages: pytz, cinrad_data, altgraph, urllib3, tzlocal, tzdata, typing_extensions, traitlets, six, PyYAML, pywin32-ctypes, pyshp, pyparsing, protobuf, platformdirs, pillow, pefile, packaging, numpy, kiwisolver, idna, greenlet, fonttools, cycler, configobj, colorama, click, charset-normalizer, certifi, SQLAlchemy, shapely, scipy, requests, python-dateutil, pyproj, pykdtree, pyinstaller-hooks-contrib, h5py, geobuf, flexparser, flexcache, donfig, contourpy, APScheduler, pyresample, pyinstaller, pooch, Pint, pandas, matplotlib, xarray, vanadis, Cartopy, MetPy, cinrad
58.19   Attempting uninstall: pillow
58.21     Found existing installation: pillow 10.2.0
58.21     Uninstalling pillow-10.2.0:
58.26       Successfully uninstalled pillow-10.2.0
59.30   Attempting uninstall: numpy
59.32     Found existing installation: numpy 1.26.4
59.32 ERROR: Cannot uninstall numpy 1.26.4, RECORD file not found. Hint: The package was installed by debian.
------
Dockerfile:28
--------------------
  26 |     # RUN pip install --ignore-installed numpy
  27 |     # RUN pip install --ignore-installed PyYAML==5.2
  28 | >>> RUN pip install --no-cache-dir -r requirements.txt
  29 |
  30 |
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install --no-cache-dir -r requirements.txt" did not complete successfully: exit code: 1


解决方案 -- 修改Dockerfile -- 强制升级numpy


# 强制升级numpy
RUN pip install numpy --ignore-installed numpy

RUN pip install --no-cache-dir -r requirements.txt

摘抄文章

posted @ 2025-01-24 15:09  zh89233  阅读(633)  评论(0)    收藏  举报