-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 330: dealing with multiple python versions and pip #331
Fix 330: dealing with multiple python versions and pip #331
Conversation
Dockerfile
Outdated
@@ -1,13 +1,19 @@ | |||
FROM ubuntu:16.04 | |||
|
|||
RUN apt-get update | |||
RUN apt-get install -y python3-pip | |||
RUN apt-get install -y wget curl python3-pip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I found using a python version manager, such as conda, pyenv, is more convenient. For example, we are using this approach in tf-plus: https://github.com/tensorflow/io/blob/master/dev/Dockerfile#L19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zou000 Thanks for the suggestion. Indeed, adding source activate tfio-dev
to ~/.bashrc
neatly isolate the Linux built-in Python2 and our Python3. This approach avoids the error-prone
# Make python3 as default Python interpreter
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN chmod +x /usr/bin/python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zou000 enabling python env in .bashrc
has certain drawbacks. For example, if you do docker run image_name bash test.sh
i.e. non-interactive bash, .bashrc
is skipped, so the python env is not activated. One workaround is to define the source activate
in entrypoint
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can think of 2 other ways:
- Invoke bash interactively e.g.
docker run image_name bash -i test.sh
- The idea of a pyenv is very simple, it just needs to find the python binary under the env root dir, e.g. in your case, you just need to modify PATH:
ENV PATH=/miniconda/envs/sqlflow-dev/bin:$PATH
I like the PATH approach better. You can verify the result by:
docker run image_name python -c 'import sys; print(sys.path)'
CI failed at
Update: |
RUN pip3 install tensorflow==2.0.0-alpha0 | ||
RUN pip3 install mysql-connector-python | ||
RUN pip3 install pyhive | ||
# Miniconda - Python 3.6, 64-bit, x86, latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are duplicating some code in .Dev, can we group the duplicated ones and add some notes in case when they need to be synchronized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix #330