Setting python3 PYTHONHOME - python-3.x

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.

Related

No module named 'distutils.util'

I'm working on ubuntu 16.0.4 LTS and While creating a virtual environment in python 3.8 I'm getting No module named 'distutils.util'
I'm using the repository: sudo add-apt-repository ppa:deadsnakes/ppa
I have tried the following but didn't work
sudo apt install python3-distutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-distutils
I have tried the solution from this link
sudo apt install python3.8-distutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.8-distutils
E: Couldn't find any package by glob 'python3.8-distutils'
E: Couldn't find any package by regex 'python3.8-distutils'
Make sure to replace 3.10 which is version of python with appropriate version.
Installing Python3.10
Update system
$ sudo apt-get update -y && sudo apt-get full-upgrade -y
Helps to add ppa repositories
$ sudo apt install software-properties-common -y
Adding deadsnake repository
$ sudo apt-add-repository ppa:deadsnakes/ppa
Installing python
$ sudo apt-get install python3.10
$ sudo apt-get install python3.10-dev
$ sudo apt-get install python3.10-tk
Add Python 3.8 & Python 3.10 to update-alternatives
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
Update Python 3 for point to Python 3.10
$ sudo update-alternatives --config python3
Installing distutils.util
$ sudo apt-get install python3.10-distutils
Still using python3.10 -m pip some_command might result in error to fix it use
$ curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

How to install pip for certain version of python3 in docker

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?

How to make an autoinstall command script for Debian

So I was working on a project that need some libraries . so I decided to made an .sh script to just install all at once but I don't know why it fails . I was searching about it , but just found how to create installer like .deb , etc
here are the commands lines that I use
install.sh
#!/bin/sh
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-pip python3-dev
sudo apt-get install build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev
sudo apt-get install python-numpy python-scipy python-matplotlib python aml
sudo apt-get install libhdf5-serial-dev python-h5py
sudo apt-get install graphviz
sudo apt-get install python-opencv
sudo apt install python-sklearn
sudo apt install python3-sklearn
pip3 install matplotlib
pip3 install pydot-ng
pip3 install tensorflow
pip3 install keras
pip3 install scikit-learn
using
bash install.sh
and I got this , I think that I'm doing just a few things wrong , I think
E: The update command takes no arguments
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package
Reading package lists... Done
Building dependency tree
Reading state information... Done
............
Can someone help me please
Your shebang at the beginning of your script is for a boot script
You're using:
#!/bin/sh
When this script should call the bash environment with:
#!/bin/bash
That should solve your problem.
As sergio states these can be done in one liners like:
#!/bin/bash
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y python3-pip python3-dev build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev python-numpy python-scipy python-matplotlib python aml libhdf5-serial-dev python-h5py graphviz python-opencv python-sklearn python3-sklearn
sudo pip3 install matplotlib pydot-ng tensorflow keras scikit-learn
At the very least utilize an array for more efficient bash programming like this:
#!/bin/bash
sudo apt-get update && sudo apt-get upgrade -y
aptDepends=(
python3-pip
python3-dev
build-essential
cmake
git
unzip
pkg-config
libopenblas-dev
liblapack-dev
python-numpy
python-scipy
python-matplotlib
python
aml
libhdf5-serial-dev
python-h5py
graphviz
python-opencv
python-sklearn
python3-sklearn
)
pipDepends=(
matplotlib
pydot-ng
tensorflow
keras
scikit-learn
)
sudo apt-get install -y "${aptDepends[#]}" && sudo pip3 install -y "${pipDepends[#]}"

Unable to install numpy and pandas in Ubuntu

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

Corresponding package names in "yum" from "apt-get"

My program has the following dependencies in Ubuntu:
apt-get install unzip wget
apt-get install mesa-common-dev -y
apt-get install libglu1-mesa-dev -y
apt-get install libfontconfig1 -y
apt-get install libglib2.0-0 -y
apt-get install libxcursor-dev libxtst-dev libxi-dev libxrender-dev -y
apt-get install libxss-dev libxcomposite-dev libxslt1-dev -y
apt-get install libasound2-dev -y
Now I also need to deploy on RHEL which uses "yum" instead of "apt-get" so my question is what is the "yum" equivalent of all the packages used above. Is there a table where they are mapped? Basically for each package above I want to know or how to find out the "yum" repository equivalent.
Also, if I'm writing a SPEC file with BuildRequires...are they all yum package names because RPM is mainly for RedHat?
RHEL variants will use -devel convention instead of -dev from debian world. Beside that the names would be similar, a yum search PKG would point out the right direction
If things get hard you can use dpkg -L PKG, grab a key file and yum whatprovides FILE to find out what packages provides that file.

Resources