Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package Python3.7 is not available

So I have python 3.8 and pip for it, but I want to install stable python 3.7 and pip for it also. But when I try sudo apt-get install python3.7 It says package is not available but is referred to another package. Help please Error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python3.7 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: Package 'python3.7' has no installation candidate
like image 245
Vasily Sobolev Avatar asked Aug 15 '20 14:08

Vasily Sobolev


3 Answers

I tried doing the below steps in an official docker image of Kali Linux. It should work on the desktop as well.

apt-get update
apt-get install -y build-essential openssl openssl-dev* wget curl
wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
tar -xvf Python-3.7.8.tgz
cd Python-3.7.8
./configure --enable-shared
make 
make test
make install

# Steps from here are to enable other libraries in linux to 
# access the shared python libraries.

cd /usr/local/lib/
cp libpython3.so /usr/lib64/
cp libpython3.so /usr/lib
cp libpython3.7m.so.1.0 /usr/lib64/
cp libpython3.7m.so.1.0 /usr/lib/
cd /usr/lib64
ln -s libpython3.7m.so.1.0 libpython3.7m.so
cd /usr/lib
ln -s libpython3.7m.so.1.0 libpython3.7m.so

Done, python3.7 is installed.

root@fe794c7ff15e:~# python3
Python 3.7.8 (default, Aug 15 2020, 16:26:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

I tried creating a python virtual environment with this install. It worked properly. I was able to install pip packages as well.

(testvirtual) root@fe794c7ff15e:~# pip install flask
Collecting flask
  Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 404 kB/s 
Collecting Jinja2>=2.10.1
  Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 10.4 MB/s 
Collecting click>=5.1
  Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 165 kB/s 
Collecting Werkzeug>=0.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 11.9 MB/s 
Collecting itsdangerous>=0.24
  Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting MarkupSafe>=0.23
  Downloading MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl (27 kB)
Installing collected packages: MarkupSafe, Jinja2, click, Werkzeug, itsdangerous, flask
Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 flask-1.1.2 itsdangerous-1.1.0
like image 94
Kaustubh Desai Avatar answered Oct 13 '22 16:10

Kaustubh Desai


Default Python version in Ubuntu nowadays is 3.8 which is per-installed. While it looks like older version of spark like 2.x versions require Python version 3.7. I ran into same issue and I did the below

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7

Updated bashrc to point PYSPARK_PYTHON environment variable to python3.7 installed above like below

export PYSPARK_PYTHON=/usr/bin/python3.7
source ~/.bashrc
like image 3
dkoder Avatar answered Oct 13 '22 16:10

dkoder


Here are the steps I follow when starting a new Python project:

First I decide on a Python release. Let's say you want to work with Python 3.7.8.

To install a specific release, I use pyenv. It's on gitbug and use this script to install it.

After installing pyenv you should cd to the place your code will be and enter pyenv install 3.7.8 and pyenv local 3.7.8 which will make sure that the Python 3.7.8 environment will be created at that location.

Then you install poetry: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python.

After poetry is installed (use poetry -V to see if it works), you can run poetry init to create a pyproject.toml file.

You can add new dependencies like this: poetry add requests.

And you can enter that environment via poetry shell.

Now your using your new project in your specific 3.7.8 python version using your dependencies in a separate shell.

like image 1
Jan Willems Avatar answered Oct 13 '22 16:10

Jan Willems