How to install Python or R in an apptainer? - python

I am new to docker and using apptainer for that.
the def file is: firstApp.def:
`Bootstrap: docker
From: ubuntu:22.04
%environment
export LC_ALL=C
`
then I built it as follows and I want it to be writable (I hope I am not so naive), so I can install some packages later:
`apptainer build --sandbox --fakeroot firstApp.sif firstApp.def
`
now I do not know how to install Python3 (preferably, 3.8 or later).
I tried to add the following command lines to the def file:
`%post
apt-get -y install update
apt-get -y install python3.8 `
it raises these errors as well even without "apt-get -y install python3.8":
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package update
FATAL: While performing build: while running engine: exit status 100

Related

Package unixodbc-bin is not available, but is referred to by another package

I was following this answer to be able to connect to an external SQL server using the Google Console Cloud Run. (https://stackoverflow.com/a/46446438/13342846)
However, I am receiving the following error when deploying
Package unixodbc-bin is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
[91mE: Package 'unixodbc-bin' has no installation candidate
[0m
unable to stream build output: The command '/bin/sh -c apt-get install unixodbc-bin -y' returned a non-zero code: 100
Failed to build the app. Error: unable to stream build output: The command '/bin/sh -c apt-get install unixodbc-bin -y' returned a non-zero code: 100
Docker file:
# Python image to use.
FROM python:3.7
# Set the working directory to /app
WORKDIR /app
# copy the requirements file used for dependencies
COPY requirements.txt .
ADD odbcinst.ini /etc/odbcinst.ini
RUN apt-get update
RUN apt-get install -y tdsodbc unixodbc-dev
RUN apt-get install unixodbc-bin -y
RUN apt-get clean -y
#....etc
I also created the odbcinst.ini file as described here: https://stackoverflow.com/a/55282188/13342846
The Python image it is using is 3.7
Any help would be appreciated!
I ran into the same problem. Replacing unixodbc-bin with unixodbc solved the problem for me.

E: Unable to locate package python-pygraphviz E: Package 'ipython' has no installation candidate

I wanted to use ns3 for which some prerequisites have to be met in Ubuntu. (https://www.nsnam.org/wiki/Installation)
First of all I cannot use apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev ipython command as it shows :E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
When I write the same command as root user,sudo apt-get install gir1.2-goocanvas-2.0 python-gi python-gi-cairo python-pygraphviz python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython ipython3
The command line interface shows,
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package ipython is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Unable to locate package python-pygraphviz
E: Package 'ipython' has no installation candidate
What should I do ? Can anybody help me?
This should work
# Install pip
sudo apt install -y python3-pip
# Install ipython
pip3 install ipython
Source: https://askubuntu.com/questions/1298398/e-package-ipython-has-no-installation-candidate-while-trying-to-install-tor
Try executing the following command:
sudo apt install ipython
then do the follwing:
sudo apt install python3-pygraphviz
or
sudo apt-get install python3-pygraphviz

Installing Python 3.8 from with a postgres Docker container

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.

Install python3 in ubuntu 16.04 docker image

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).

Pycharm: Compile Cython Extensions Error - unable to execute 'gcc': No such file or directory

On Ubuntu 14.04, I use Pycharm Professional Edition. When I start a debug session, I see the following message in the event log of Pycharm:
Python Debugger Extension Available
Cython extension speeds up Python debugging
Install How does it work
Clicking on Install leads to a popup window with an error message:
I depict here the text, too, so that it can be found by others more easily:
Compile Cython Extensions Error
Non-zero exit code (1):
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
To look for a solution:
I compiled Cython speedups manually according to the link mentioned above: /usr/bin/python3 /<PYCHARM_INSTALLATION_PATH>/helpers/pydev/setup_cython.py build_ext --inplace. This finishes successfully, but does not help with the error message.
I added the python-3.6-dev repository:
sudo add-apt-repository ppa:deadsnakes/ppa, executed: sudo apt-get update && sudo apt-get dist-upgrade
and installed python-3.6-dev: sudo apt-get install python3.6-dev
It finishes successfully, but does not change the above popup error message.
What else can I check or execute?
EDIT
regarding the installation of gcc, it looks like the following:
user#user-computer:~$ gcc
The program 'gcc' is currently not installed. You can install it by typing:
sudo apt-get install gcc
user#user-computer:~$ sudo apt-get install gcc
[sudo] password for user:
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version.
The following packages were automatically installed and are no longer required:
libseccomp2 libwireshark5 libwiretap4 libwsutil4
linux-image-3.13.0-160-generic linux-image-extra-3.13.0-160-generic
linux-lts-xenial-tools-4.4.0-137 linux-signed-image-4.4.0-137-generic
linux-tools-4.4.0-137-generic squashfs-tools
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
user#user-computer:~$ gcc
The program 'gcc' is currently not installed. You can install it by typing:
sudo apt-get install gcc
At first:
sudo apt install --reinstall gcc
Then run commands below depends on version of Python , you are using:
For Python 2.x use:
$ sudo apt-get install python-dev
For Python 3.x use:
$ sudo apt-get install python3-dev
For Python 3.8 use:
$ sudo apt-get install python3.8-dev
For future reference:
Cython uses gcc (by default), need to verify it is installed and working properly.
As it installed by default on most recent Ubuntu distributions, if it is not working well, you can follow OP fix and use sudo apt install --reinstall gcc

Categories