我正在用requirements.txt檔案構建一個Docker鏡像。每次我構建鏡像時,都會因為某些軟體包的版本不存在而導致失敗。比如說
ARG BASE_CONTAINER=tensorflow/tensorflow
從$base_container
# 2) 更改為root來安裝軟體包。
USER root
COPY requirements.txt requirements.txt
# 3) 安裝軟體包
RUN pip install -r requirements.txt
ERROR: Could not find a version that satisfies the requirement msrestazure==0.5.4.
(from -r requirements.txt (line 66)) (from versions: 0.0.1, 0.0.2, 0。 1.0, 0.1.1,0.1,
0.2.0, 0.2.1, 0.3。 0, 0.4.0rc1, 0。 4.0, 0.4。 1, 0.4.2, 0.4.3, 0.4。 4, 0.4.5, 0。 4.6, 0.4.7,
0.4.8, 0.4.9, 0.4。 10, 0.4.11, 0.4.12, 0。 4.13, 0.4.14, 0.4.15, 0。 4.16, 0.4.17, 0.40.18,
0.4.19, 0.40.20, 0.4. 21, 0.4.22, 0.4.23, 0。 4.24, 0.4.25, 0.40.26, 0. 4.27, 0.4.28, 0.4.29,
0.4.30, 0.4.31, 0.4. 32, 0.4.33, 0.4.34, 0.5。 0, 0.5.1, 0.6.0, 0.6。 1, 0.60.2, 0. 6.3, 0.6.4)
#6 9.178 ERROR: No matching distribution found for msrestazure==0.5.4 (from -r requirements.txt (line 66))
為了解決這個問題,我一直在修改requirements.txt中軟體包的版本,將其改為docker可以找到的最新的版本。我想知道是否有辦法以編程的方式做到這一點。例如,如果我的requirements.txt檔案中的版本不存在/無法找到,我是否可以使用一些標志或選項來自動安裝docker可以找到的最新版本的軟體包?
uj5u.com熱心網友回復:
在requirements.txt中完全不指定任何版本將導致使用最新的版本,只要它不沖突。
在你的案例中,我建議運行docker run -it tensorflow/tensorflow以在環境中獲得一個互動式的 shell,然后在不指定版本的情況下安裝你的所有軟體包。測驗是否有效,如果有效,運行pip freeze > requirements.txt來生成一個新的需求檔案,在該環境下作業,這樣你的需求就可以穩定了。
你還必須釘住tensorflow/tensorflow影像,因為如果你像現在這樣使用latest,那么你就不能確定你的需求在未來會被使用。
請確保在退出容器之前將requirements.txt檔案復制出來。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/331579.html
標籤:
