Installieren Sie Cython mit Python3 in Docker

Installieren Sie Cython mit Python3 in Docker

Ich verwende ein Docker-Image tensorflowvon python3:

FROM tensorflow/tensorflow:latest-gpu-py3

Ich brauche Cythoneine Bibliothek von Drittanbietern, also

RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
    python get-pip.py && \
    rm get-pip.py

RUN \ 
    pip install --no-cache-dir Cython

Das Problem besteht darin, dass ich danach Cythonvon sehen kann python, aber nicht von python3:

root@fdb5bb783cf9:/darkflow# python3 -c "import Cython; print(Cython.__version__)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'Cython'
root@fdb5bb783cf9:/darkflow# python -c "import Cython; print(Cython.__version__)"
0.25.2

Antwort1

Ich habe festgestellt, dass die Lösung darin besteht, sowohl die Installation als auch die Ausführung pip3der Bibliothek zu verwenden, also:Cythonpython3setup.py

RUN apt-get update && apt-get install -y \
    python3-pip

Und

RUN \ 
    pip3 install --no-cache-dir Cython

und die Bibliotheksebene

RUN \
    cd lib && \
    python3 setup.py

Die letzte Möglichkeit hätte eine pip3 install .globale Installation mit sein können pip3.

Dieses Mal

RUN python3 -c "import Cython; print(Cython.__version__)"

Ich hatte Cythonda:0.25.2

verwandte Informationen