我正在嘗試為機器學習專案構建運行 Python 3.7 的 Ubuntu 18.04 Docker 映像。使用pipfrom安裝特定 Python 包時requirements.txt,出現以下錯誤:
Collecting sklearn==0.0
Downloading sklearn-0.0.tar.gz (1.1 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
[end of output]
盡管這里的錯誤出現在 的背景關系中sklearn,但問題并不特定于一個庫;當我洗掉該庫并嘗試重建影像時,其他庫會出現錯誤。
這是我的Dockerfile:
FROM ubuntu:18.04
# install python
RUN apt-get update && \
apt-get install --no-install-recommends -y \
python3.7 python3-pip python3.7-dev
# copy requirements
WORKDIR /opt/program
COPY requirements.txt requirements.txt
# install requirements
RUN python3.7 -m pip install --upgrade pip && \
python3.7 -m pip install -r requirements.txt
# set up program in image
COPY . /opt/program
我試過的:
- 在使用 ;安裝要求之前,
python-devtools安裝;python3.7-devpip setuptools在安裝requirements.txt受影響的庫之前安裝。
在這兩種情況下,都出現了相同的錯誤。
您知道在安裝類似的庫時如何確保setuptools在我的環境中可用sklearn嗎?
uj5u.com熱心網友回復:
正如評論中提到的,setuptools在pip運行之前安裝pip install -r requirements.txt。
它與將其放在setuptools更高的位置不同,requirements.txt因為它在需求檔案收集所有軟體包并在之后安裝它們時強制執行順序,因此您無法控制順序。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/431611.html
