python – How to install pip for python3.7 only?

python – How to install pip for python3.7 only?

Download get-pip file

$curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Install pip for python3.7

$python3.7 get-pip.py

Check versions for both

$python3.7 -V && pip3 -V
Output:
Python 3.7.3
pip 19.1.1 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)

Deadsnakes

You can use a ppa called deadsnakes.

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7

Then check that is has been installed successfully by running python3.7 --version. To use pip you can run python3.7 -m pip install package.

Compiling from source

You can build Python by yourself, on Debian based systems you would do:

sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev 
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm 
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Download your preffered python version from https://www.python.org/ftp/python/

Then extract the tar archive and run make

./configure --enable-optimizations
make
sudo make altinstall

Then run python3.7 --version

python – How to install pip for python3.7 only?

if you check apt show python3-pip output you see it depends on python3:any (>= 3.4~) so it doesnt strictly say I need python3.6

I assume that you didnt install python3.7 using apt so as a result apt doesnt recognize that you have python3 and it tries to install it for you.

Leave a Reply

Your email address will not be published.