在我的代码中,我使用的是 configparser:
from configparser import ConfigParser
我正在使用 pip freeze 来生成我的 requirements.txt
pip freeze > requirements.txt
而对于 configparser 它正在写
configparser==3.3.0.post2
但是,当我pip install -r requirements.txt
通过 docker build 从 docker 容器中执行操作时,这会失败:
docker build -t denzel .
Downloading/unpacking configparser==3.3.0.post2 (from -r /home/denzel/requirements.txt (line 2))
Could not find a version that satisfies the requirement configparser==3.3.0.post2 (from -r /home/denzel/requirements.txt (line 2)) (from versions: 3.2.0r1, 3.2.0r2, 3.2.0r3, 3.3.0r1, 3.3.0r2, 3.5.0b1, 3.5.0b2)
Cleaning up...
No distributions matching the version for configparser==3.3.0.post2 (from -r /home/denzel/requirements.txt (line 2))
但这可以通过以下方式在本地工作pip install
:
pip install -r requirements.txt
Requirement already satisfied (use --upgrade to upgrade): aniso8601==1.1.0 in ./env/lib/python2.7/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): configparser==3.3.0.post2 in ./env/lib/python2.7/site-packages (from -r requirements.txt (line 2))
....
....
注意:我通过删除版本并仅使用configparser
, 没有版本来解决此问题。仍然想发布我的问题以了解它失败的原因。