I'm trying to install and setup a pyenv within a Dockerfile (FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04
)
Here is the second half of the Dockerfile ( the first half is just installing dependencies ) :
RUN useradd -ms /bin/bash user && echo "user:resu" | chpasswd && adduser user sudo
USER user
WORKDIR /home/user
# install pyenv
RUN git clone git://github.com/yyuu/pyenv.git .pyenv
ENV HOME /home/user
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> .bashrc
RUN echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> .bashrc
RUN echo 'eval "$(pyenv init -)"' >> .bashrc
RUN pyenv install 2.7.10
# install pyenv-virtualenv
RUN git clone https://github.com/yyuu/pyenv-virtualenv.git .pyenv/plugins/pyenv-virtualenv
RUN echo 'eval "$(pyenv virtualenv-init -)"' >> .bashrc
# setup virtualenv
RUN pyenv virtualenv 2.7.10 foo
RUN /bin/bash -c ' source .bashrc && \
pyenv activate foo && \
pip install numpy && \
pip install nltk'
The Docker installation fails on the last line with :
Step 20 : RUN /bin/bash -c ' source .bashrc && pyenv activate foo && pip install numpy && pip install nltk'
---> Running in 672826e55a40
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
What is the problem here ? Is there a best-practice for setting up pyenvs with Docker ?
pyenv activate
, just replacepip
with$PYENV_ROOT/versions/foo/bin/pip
. – Ullman