简体   繁体   中英

Pip for Python 3.8

How do I install Pip for Python 3.8? I made 3.8 my default Python version.

sudo apt install python3.8-pip gives unable to locate package python3.8-pip python3.8 -m pip install [package] gives no module named pip I can't run sudo apt install python3-pip because it installs pip for Python 3.6

What people use?

Install pip the official way :

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

made 3.8 my default Python version

It depends on how you did that, but it might break something in your OS. For example some packages on Ubuntu 18.04 might depend on python being python2.7 or python3 being python3.6 with some pip packages preinstalled.

sudo apt install python3.8
sudo apt install python3.8-distutils

wget https://bootstrap.pypa.io/get-pip.py
sudo python3.8 get-pip.py

If you installed Python3.8 using apt , the pip documentation advises against using the get-pip.py script:

Be cautious if you are using a Python install that is managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.

The same page suggests running:

python3.8 -m pip --version

to determine if pip is already installed. I installed Python 3.8 on an Ubuntu18 machine using apt install python3.8 , and I verified with the command above that it includes pip. It appears that Ubuntu package doesn't install a pip command that you can run directly. But you can run it using the python3.8 binary directly instead, anywhere you would have used pip :

python3.8 -m pip install [package]

you can try updating line #1 from /usr/bin/pip3 to #./usr/bin/python3.8 as below

#!/usr/bin/python3.8
# GENERATED BY DEBIAN

import sys

# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
from pip import main
if __name__ == '__main__':
    sys.exit(main())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM