在python 3 docker镜像中安装CyLP的正确方法。

问题描述 投票:0回答:1

我一直试图从python3的docker镜像,Dockerfile中安装CyLP。

FROM python:3

#EXPOSE 42400-42500

RUN mkdir -p /usr/src/metis

WORKDIR /usr/src/metis

RUN apt-get update

COPY requirements.txt .


# Install Cbc
RUN wget https://www.coin-or.org/download/source/Cbc/Cbc-2.9.9.tgz \
    && tar -xzf Cbc-2.9.9.tgz \
    && cd Cbc-2.9.9 \
    && ./configure --enable-cbc-parallel \
    && make \
    && make install \
    && rm -rf /usr/src/metis/Cbc-2.9.9.tgz

ENV COIN_INSTALL_DIR=/usr/src/metis/Cbc-2.9.9
ENV LD_LIBRARY_PATH=/usr/src/metis/Cbc-2.9.9/lib:$LD_LIBRARY_PATH

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

# Add GCC needed to compile CyLP
# RUN apt-get install python3-dev -y \
#     python-dev \
#     build-essential \
#     manpages-dev

# RUN gcc --version

# # Install CyLP

# COPY CyLP-py3 CyLP-py3

# WORKDIR  /usr/src/metis/CyLP-py3

# RUN COIN_INSTALL_DIR=/usr/src/metis/Cbc-2.9.9 python setup.py install 

WORKDIR /usr/src/metis/

COPY . .


RUN rm -rf /usr/src/metis/cylp-master.tar.gz
CMD [ "python3", "./main.py" ]

我甚至尝试从源码下载并编译它,但仍然得到了一些错误,在requirements.txt中尝试安装时出现的错误。

pika==1.1.0
numpy==1.17
scipy==1.4.1
cylp==0.9.3

错误:

Step 9/13 : RUN pip install  -r requirements.txt --no-cache-dir
 ---> Running in 101f73aa508a
Collecting pika==1.1.0
  Downloading pika-1.1.0-py2.py3-none-any.whl (148 kB)
Collecting numpy==1.17
  Downloading numpy-1.17.0.zip (6.5 MB)
Collecting scipy==1.4.1
  Downloading scipy-1.4.1-cp38-cp38-manylinux1_x86_64.whl (26.0 MB)
Collecting cylp==0.9.3
  Downloading cylp-0.9.3.tar.gz (1.4 MB)
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-p8n5a_rr/cylp/setup.py'"'"'; __file__='"'"'/tmp/pip-install-p8n5a_rr/cylp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-p8n5a_rr/cylp/pip-egg-info
         cwd: /tmp/pip-install-p8n5a_rr/cylp/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-p8n5a_rr/cylp/setup.py", line 5, in <module>
        import numpy
    ModuleNotFoundError: No module named 'numpy'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

即使numpy安装在cylp之前,也一直在尝试用不同版本的numpy,但没有成功。

有什么提示可以解决这个问题,为什么会出现这种情况,以及如何正确安装CyLP for python3?

python docker
1个回答
0
投票

已经有一个安装了CyLP的Python3的docker镜像。

https:/hub.docker.comrtkralphscylp。

© www.soinside.com 2019 - 2024. All rights reserved.