Install Cython with python3 in Docker
7,010
I have found that the solution was to use pip3
to run Cython
install as well as python3
to run the setup.py
of the library, so:
RUN apt-get update && apt-get install -y \
python3-pip
and
RUN \
pip3 install --no-cache-dir Cython
and the library layer
RUN \
cd lib && \
python3 setup.py
The last one could have been pip3 install .
to install globally using pip3
.
This time doing
RUN python3 -c "import Cython; print(Cython.__version__)"
I had Cython
there: 0.25.2
Related videos on Youtube
Author by
loretoparisi
Computer Engineer. Technical Director of Machine Learning @musixmatch
Updated on September 18, 2022Comments
-
loretoparisi over 1 year
I'm using a Docker image from
tensorflow
withpython3
:FROM tensorflow/tensorflow:latest-gpu-py3
I need
Cython
for a 3rd party library to be there, so I doRUN curl -O https://bootstrap.pypa.io/get-pip.py && \ python get-pip.py && \ rm get-pip.py RUN \ pip install --no-cache-dir Cython
The problem is that after that I can see
Cython
frompython
, but not frompython3
: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
-
OscarAkaElvis about 7 yearsAre you sure the image you are using has python3? is tagged as it is... but I repeat, are you sure?
-
loretoparisi about 7 yearsThanks I have just realized I have missed something:
apt-get install python3-pip
, andpip3 install --no-cache-dir Cython
, after that it worked! -
OscarAkaElvis almost 7 yearsOk so put the answer yourself and mark it as resolved.
-