I am confronted with a somewhat unexpected problem - I am having problems installing Python 3.8 in a Docker container.
I have created a Dockerfile that is intended to serve as my test DB. As part of its creation, it needs to run a Python script to populate it with test data. However, I cannot do what I thought would be the easiest step: installing Python.
FROM postgres
# Install Python dependencies ---------
RUN apt-get update && apt dist-upgrade -y
RUN apt install software-properties-common --yes
RUN apt-get install ca-certificates --yes
RUN gpg-agent --daemon --enable-ssh-support
RUN add-apt-repository ppa:deadsnakes/ppa --yes
RUN apt install python3.8 --yes
RUN python3.8 --version
Somewhat to my surprise, only Python 3.7 is available through apt-get. The approved method for getting Python 3.8 it to use deadsnakes - but this creates the following errors:
Step 12/33 : RUN add-apt-repository ppa:deadsnakes/ppa --yes
---> Running in 17d490c0b568
gpg: keybox '/tmp/tmp8n9r_96q/pubring.gpg' created
gpg: /tmp/tmp8n9r_96q/trustdb.gpg: trustdb created
gpg: key BA6932366A755776: public key "Launchpad PPA for deadsnakes" imported
gpg: Total number processed: 1
gpg: imported: 1
Warning: apt-key output should not be parsed (stdout is not a terminal)
gpg: no valid OpenPGP data found.
As per various posts I've found, I've added:
RUN apt-get install ca-certificates --yes
RUN gpg-agent --daemon --enable-ssh-support
And although they appear to do no harm (and the latter appears to get rid of a second error message from gpg), they do not solve the problem...
OK, it seems that installing Python 3.8 (while the latest distribution is Python 3.7) on a debian container is more trouble than it was worth.
My workaround was to create a second Docker container running Python. This populated the Postgres container in a one-off operation.
Related
I have an Ubuntu VM without internet access. It currently has Python 3.10 installed but I want to update to Python 3.11 (the latest at the time of this post).
On a machine with internet access, I used apt to download Python3.11.
mkdir python_3.11
apt-get --download-only -o Dir::Cache="./python_3.11/" -o Dir::Cache::archives="./python_3.11/" install python3.11
$ ls python_3.11
libpython3.11-minimal_3.11.0~rc1-1~22.04_amd64.deb pkgcache.bin
libpython3.11-stdlib_3.11.0~rc1-1~22.04_amd64.deb python3.11-minimal_3.11.0~rc1-1~22.04_amd64.deb
lock python3.11_3.11.0~rc1-1~22.04_amd64.deb
partial srcpkgcache.bin
After transferring the files onto the VM, I tried running sudo dpkg -i on each of the files. This eventually "installed" them but opening a python shell still shows the old 3.10 version. /usr/bin/python3 still points to /usr/bin/python3.10 and this is no /usr/bin/python3.11.
Another thing I've tried
# on the machine im trying to install
sudo apt-get update -oDir::Cache::archives="/path/to/downloaded/packages" --no-install-recommends --no-download
sudo apt-get -oDir::Cache::archives="/path/to/downloaded/packages" --no-install-recommends --no-download install python3.11-minimal
This ends up returning
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
I've since added the following to the download command. python3.11-minimal libpython3.11-stdlib python3.11 libpython3.11-minimal python3.11-venv python3.11-doc binfmt-support python3-pip-whl python3-setuptools-whl. During the install, I'm still getting the same error message on "Unable to fetch some archives".
There are 2 commands that need to be run. I'm not 100% sure the first one (the update) is necessary. It is important that the paths are absolute. Assuming the required packages have been downloaded, it should install.
apt-get -oDir::Cache::archives="/absolute/path/" -oDir::Cache="/absolute/path" --no-install-recommends --no-download update
apt-get -oDir::Cache::archives="/absolute/path/" -oDir::Cache="/absolute/path/" --no-install-recommends --no-download install python3.11
I am trying to install Python 3.9 on Linux 4.4 in Cloudera Data Science Workbench (cdsw).. I do not have sudo rights and I wont be able to connect to any websites.
The current version of python is 3.6
Following the procedure as mentioned here.
However, on step "sudo make altinstall" I get the error "permission denied" on /usr/local/bin
Is there any workaround to make this step work?
This is the last step of the whole procedure.
You can use the method on top and install using apt... It's the best way to do it,
sudo apt update
sudo apt install software-properties-common
Followed by adding the repository,
sudo add-apt-repository ppa:deadsnakes/ppa
Accept the changes, then
sudo apt install python3.9
Now, whenever you want to use python3.9 you have to invoke python3.9 instead of python3.
If you are using cloudera, cdsw, you cannot get sudo rights, you need to follow this guide to install packages,
https://docs.cloudera.com/documentation/data-science-workbench/1-8-x/topics/cdsw_extensible_engines.html
Follow the guide above, then change the docker file like this
# Dockerfile
FROM docker.repository.cloudera.com/cdsw/engine:8
RUN rm /etc/apt/sources.list.d/*
RUN apt-get update
RUN apt install software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt install python3.9 python3-pip \
&& rm /etc/apt/sources.list.d/*
RUN pip install pandas numpy
Then follow the rest of the guide for steps 2-4, you should be able to get your desired outcome.
I created Dockerfile and docker-compose but gives me this error django-apache2 exited with code 0 when I write docker-compose up
Dockerfile
FROM ubuntu:18.04
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get -y install python3.8
RUN apt-get -y install python3-pip
RUN apt -y install apache2
RUN apt-get install -y apt-utils vim curl apache2 apache2-utils
RUN apt-get -y install python3 libapache2-mod-wsgi-py3
RUN pip3 install --upgrade pip
COPY ./requirements.txt ./requirements.txt
RUN apt-get -y install python3-dev
RUN apt-get -y install python-dev default-libmysqlclient-dev
RUN pip3 install -r ./requirements.txt
COPY ./apache.conf /etc/apache2/sites-available/000-default.conf
RUN mkdir /var/www/api/
COPY ./project/. /var/www/api/
WORKDIR /project/
Docker-compose
version: "3"
services:
django-apache2:
container_name: "django-apache2"
build: .
ports:
- "8005:80"
First, we need to understand that a Docker container runs a single command. The container will be running as long as that process the command started is running. Once the process is completed and exits then the container will stop.
With that understanding, we can make an assumption of what is happening in your case. When you start your service there is no command. At this point, the Docker container is stopped because the process exited (with status 0).
So you need to add command that keeps running on your docker.
Check this link for more information Here.
Your container lacks something to run. You need to add a CMD or ENTRYPOINT instruction to your Dockerfile.
That's why you see such message, which is not an error. The message is telling you that your container django-apache2 finished correctly (exit status 0), and this is because you are running the base image ubuntu which doesn't execute anything.
The problem with this approach is due to www-data apache2 user. If you install python packages from Dockerfile they will be installed for superuser and www-data apache user can not access those packages.
I tried creating a new venv using pip and the same problem happens. Packages installed from superuser in a python virtual environment are not installed inside venv folder.
I created a new repository in github explaining a different approach using miniconda3 as the python packages manager and using sudo -u in order to run commands as a different user.
I am trying to solve this using pip. Changes will be posted in the repository.
I hope this can be useful to you.
I am trying to install python 3.6 in ubuntu 16.04 docker image. It was working fine before. But today it is started showing this error.
Step 8/14 : RUN add-apt-repository ppa:jonathonf/python-3.6
---> Running in a27c7c55afef
This PPA has been removed from public access as part of a protest against the abuse of open-source projects by large companies. For more detail visit the main page here: https://launchpad.net/~jonathonf
If you are a company and you would like this PPA to continue then let me know your preferred route for contributions and I will arrange something.
Ign:8 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main all Packages
Err:7 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 Packages
404 Not Found
Ign:8 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main all Packages
Reading package lists...
W: The repository 'http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial Release' does not have a Release file.
E: Failed to fetch http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
I am not sure about this. I didn't understand the problem. How I can solve this issue.
My docker code below:
FROM ubuntu:16.04
COPY requirements.txt /
RUN apt-get update
RUN apt-get install -y software-properties-common vim
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv python-dev libssl-dev swig
RUN apt-get install -y git
# update pip
RUN python3.6 -m pip install pip --upgrade
RUN python3.6 -m pip install wheel
RUN pip install -r requirements.txt
Is anyone facing the same issue?
Thanks in advance.
The error you're getting seems pretty obvious:
This PPA has been removed from public access as part of a protest against the abuse of open-source projects by large companies. For more detail visit the main page here: https://launchpad.net/~jonathonf
The author has removed the PPA you're trying to use. You will need to find another PPA, or install Python yourself from source, or use a different base image. For example, you could use the standard python:3.6 base image if you need Python 3.6 (or just python:3.7 or python:3.8, depending on your needs).
I am having a tough time installing lxml for python 3.6 onto a BeagleBone Black (Debian GNU/Linux version 9).
Based on this article, one can run this command:
sudo apt-get install libxml2-dev libxslt-dev python-dev
Then this:
sudo apt-get build-dep python3-lxml
However, when I run the 2nd command, I get this error:
E: You must put some 'source' URIs in your sources.list
Based on this answer, I need to modify sources.list
How can I get past this error and install lxml library for Python 3?
BTW when I run the command:
sudo apt-get install python3-lxml
It fails with a long message that boils down to
arm-linux-gnueabihf-gcc: internal compiler error: Killed (program cc1)
You have to add something like (you can use a different mirror) deb-src http://deb.debian.org/debian/ stretch main in your sources.list and then run apt update and finally re-run the apt-get build-dep python3-lxml command.