在我的代码中,我使用的是configparser:
from configparser import ConfigParser
我正在使用pip冻结来生成我的requirements.txt
pip freeze > requirements.txt
对于configparser,它正在编写
configparser==3.3.0.post2
但是当我通过docker build从docker容器中执行pip install -r requirements.txt
时失败了:
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
来修复此问题,没有版本。仍然想发布我的问题,以了解它失败的原因。
答案 0 :(得分:0)
以下内容适用于docker
app.py
from configparser import ConfigParser
config = ConfigParser()
config.read('app.conf')
_var = config.get(‘Section’, 'Status')
print (_var)
requirements.txt
configparser
以下操作将在本地进行
app.py
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('app.conf')
_var = config.get(‘Section’, 'Status')
print (_var)