I'm trying to run docker:
FROM nvcr.io/nvidia/l4t-base:r32.6.1 as base
COPY requirements.txt /tmp/r.txt
RUN apt update && apt install -y python3.7
RUN update-alternatives --install /usr/local/bin/python python /usr/bin/python3.6 20 && \
update-alternatives --install /usr/local/bin/python python /usr/bin/python3.7 40
RUN apt-get -yqq update && \
apt install -y python3-pip gcc
The image nvcr.io/nvidia/l4t-base:r32.6.1 has ubuntu 18.04 and python 3.6 installed. I want to make image with python 3.7 as default.
But when I build container from the following image pip3 is from python 3.6. And after I run pip install it install all libraries for python 3.6.
root#localhost:/# pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
But I want that libraries to be for python 3.7.
I tried to delete python3.6 the docker file is:
FROM nvcr.io/nvidia/l4t-base:r32.6.1 as base
RUN apt-get -y purge python3.6 && \
apt-get -y autoremove
RUN apt-get -yqq update && \
apt install -y python3.7 python3-pip gcc
But again pip3 is for python 3.6.
Any thoughts?
Related
This is the part of my Dockerfile that installs Python and my code's dependencies.
FROM ubuntu:18.04
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && apt-get update && apt-get install -y \
python3.8 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/pip3 /usr/bin/pip
# Update Python with the required packages
RUN pip install --upgrade pip
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
The image gets created and then when I ran the code I got this error back
q9zp213vt4-algo-1-cqgxl | /usr/local/lib/python3.6/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
This message alerted me to the use of Python 3.6 and when I checked my image's Python version using the CLI I could indeed see it was the default Python version 3.6.9.
Apologies for this basic question, but I'm not familiar with working with Docker and I'm not sure where I'm going wrong. The Base image of Ubuntu cannot be changed.
You need to set the specific Python 3 version. RUN ln -s /usr/bin/python3 /usr/bin/python only tells Ubuntu to use the default Python 3 instead of Python 2, but not which Python 3. On my computer, python3 is linked to python3.10. You can forcibly replace the version with RUN ln -fs /usr/bin/python3.8 /usr/bin/python3
Sorry I am newbie, when I try to install pip using following command
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
I get following error
ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
Please help me out
Well you have two options, either use python3 with
sudo apt install python3 -y
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
Or install it with python2:
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python get-pip.py
But if you just want to install pip you can do it with:
sudo apt install python3-pip -y
or
sudo apt install python-pip -y
I already tried
sudo apt-get install build-essential python-dev python-setuptools
sudo apt-get install python-numpy python-scipy
sudo apt-get install libatlas-dev libatlas3gf-base
It was showing Unable to locate package libatlas3gf-base
So I tried
pip install --user --install-option="--prefix=" -U scikit-learn
But it failed. Failure is in the image as shown in this drive link "https://drive.google.com/open?id=1_YZlQYpP5aGGbbEDKzIzsYeiEVIgEmGe".
Try installing with pip
sudo apt-get install python3-pip
sudo pip install pandas or sudo pip3 install pandas
sudo pip install numpy or sudo pip3 install numpy
Try also using a virtual enviroment just in case
apt-get install python-virtualenv
virtualenv testVirtualEnv
cd testVirtualEnv
source bin/activate
Now install dependencies
Virtual enviroments are also a good way of making projects in a more managable way
I installed python3 and pip3 using:
RUN apt install -y build-essential libssl-dev libffi-dev python3-dev
RUN apt install -y python3-pip
For some reason site-packages are showing up like this:
root#5d6f29f1d4e9:/usr/local/lib/python2.7# ls -a
. .. dist-packages site-packages
root#5d6f29f1d4e9:/usr/local/lib/python3.6# ls -a
. .. dist-packages
My only guess is that I should set PYTHONHOME to point to 3.x instead of 2.x? e.g.:
ENV PYTHONHOME /usr/local/lib/python3.6
(note I am root user in a docker container so just need one python version and I won't need virtualenv / venv).
Nah I don't think this was it. I did this:
RUN apt install -y build-essential libssl-dev libffi-dev python3-dev
RUN apt install -y python3-pip
ENV PYTHONHOME /usr/local/lib/python3.6
RUN pip3 install awscli
and it then failed with some unnecessary error when installing awscli, so setting this env var doesn't seem like the right thing to do.
I have a Python file, in which I tried to import Spark libraries.
When I built it with the Docker File it is giving me error as 'JAVA_HOME' is not set.
I tried to install Java through Docker file, but it is giving error as well.
Below is the Dockerfile I tried to execute.
FROM python:3.6.4
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:webupd8team/java -y && \
apt-get update && \
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y oracle-java8-installer && \
apt-get clean
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
ADD Samplespark.py /
COPY Samplespark.py /opt/ml/Samplespark.py
RUN pip install pandas
RUN pip install numpy
RUN pip install pyspark
RUN pip install sklearn
RUN pip install sagemaker_pyspark
RUN pip install sagemaker
CMD [ "python", "./Samplespark.py" ]
ENTRYPOINT ["python","/opt/ml/Samplespark.py"]
Please help me to install the Java dependencies for PySpark in Docker.
You have Debian os, not ubuntu os. These ppas are for ubuntu os. According to this, article oracle java8 is not available in Debian due to licensing issues.
You have following options-
1. Use an Ubuntu docker image which comes with preinstalled oracle java8 like this one
2. Follow this tutorial on how to install Oracle java8 on Debian Jessie
3. Install open_jdk sudo apt-get install openjdk-8-jre