web123456

ubuntu python3.8 install pip_Ubuntu install python3.8

Ubuntu 16.04 amd64 (64bit) (Pure Edition)

comes with python 2.7 and python 3.5

Run "whereis python" to see what python is currently installed.

[root@root ~]# whereis python

python: /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /usr/share/man/man1/python.

0. Configure the dependency environment, if you don't do this step there may be some problems

sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev

wget /ftp/python/3.8.1/Python-3.8.

# If the download fails

1. Change the server DNS to 8.8.8.8.

2. Change the source to Tsinghua or Douban source

2. Unzip the downloaded package

The first method

tar -xvJf Python-3.8.

The second method

#Unzip

xz -d Python-3.8.

tar -xf Python-3.8.

3. Enter the unzipped directory

cd Python-3.8.1/

4. Installation of dependencies (non-essential, you can skip this step, such as in step 5 error in the implementation of this step)

Execute the following commands to install the dependency process, always y if prompted.

sudo apt-get install python-dev

sudo apt-get install libffi-dev

sudo apt-get install libssl-dev

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev

5. Execute the installation

./configure prefix=/usr/local/python3

make && make install

6. Modify the soft connection (configure global variables)

#Backup the original link

mv /usr/bin/python /usr/bin/

#add softlinks for python3

ln -s /usr/local/python3/bin/python3 /usr/bin/python

#Test if the installation was successful

python -V

7. Install/upgrade pip

Perform the installation

# This line is for (python2.7 install pip)

sudo apt-get install python-pip

#This installs pip for python3.

sudo apt-get install python3-pip

Implementation upgrade

pip install --upgrade pip

pip3 install --upgrade pip

The following problem occurs when upgrading pip:

Traceback (most recent call last):

File "/usr/bin/pip", line 9, in

from pip import main

Just use the command

python -m pip install –upgrade pip

There are two ways to install Python on ubuntu

Mode 1

1. Run the following command as root or as a user with sudo access to update the package list and install the required components:

2. $ sudo apt update

$ sudo apt install software-properties-common

3. Add the Deadsnakes PPA to the system's source list:

$ sudo add-apt-repository ppa:deadsnakes/ppa

4. After enabling the repository, install Python 3.8 using the following command:

$ sudo apt install python3.8

5. Verify that the installation was successful by typing the following command:

$ python3.8 --version

Mode 2

1. Update the package list and install the packages needed to build Python:

$ sudo apt update

$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

2. Use wget to download the latest version of the source code from the Python download page, or visit the / website to download it:

$ wget /ftp/python/3.8.0/Python-3.8.

At the time of choosing to write this article, the latest version was 3.8.0.

3. Once the download is complete, unzip the downloaded file:

$ tar -xf Python-3.8.

4. Switch to the Python source directory and execute the configure script, which performs a number of checks to ensure that all dependencies are present on the system:

$ cd Python-3.8.0

$ ./configure --enable-optimizations

The --enable-optimizations option optimizes Python binaries by running multiple tests, which can slow down the build process.

5. Start the Python 3.8 build process:

$ make -j 8

To speed up build time, modify -j to correspond to the number of cores in the processor; you can find the number by typing nproc.

6. Once the build process is complete, enter the following command to install the Python binaries:

$ sudo make altinstall

Do not use the standard make install as it will overwrite the default system python3 binary.

7. Python 3.8 is installed and ready to use, as verified by running the following command:

$ python3.8 --version

The output should show the Python version: