First of all, the linux
system comes with python2
, so you can use the python
command directly. Note that the installation of python2
cannot be uninstalled
rpm
sudo yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
deb
sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libsqlite3-dev
First install the dependencies first, and then install python
will not automatically install pip
ftp
site
https://www.python.org/ftp/python
Find the package that needs to be downloaded in the above page, and then use the command
wget https://www.python.org/ftp/python/3.5.4/Python-3.5.4.tar.xz
After the download is complete, you can see the downloaded file in the directory where the wget
command is currently running
Then the tar
command to decompress, as follows
tar -xf Python-3.5.4.tar.xz
You will get a folder named Python-3.5.4
Create a folder that needs to store the installation files, such as the path I created /usr/local/python3/
mkdir -p /usr/local/python3
Then cd
enters Python-3.5.4
Compile and install
sudo ./configure --prefix=/usr/local/python3/
sudo make
sudo make install
After executing make install
, the output is as follows
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0[root@10-9-183-29 Python-3.5.4]#
That means the installation is complete, and pip
is installed
Then check the structure information of the installation path such as
[ root@10-9-183-29 Python-3.5.4]# cd /usr/local/python3/[root@10-9-183-29 python3]# ls
bin include lib share
[ root@10-9-183-29 python3]#
[ root@10-9-183-29 python3]# cd bin
[ root@10-9-183-29 bin]# ls
2 to3 2to3-3.5 easy_install-3.5 idle3 idle3.5 pip3 pip3.5 pydoc3 pydoc3.5 python3 python3.5 python3.5-config python3.5m python3.5m-config python3-config pyvenv pyvenv-3.5[root@10-9-183-29 bin]# ls -l
total 24128
lrwxrwxrwx 1 root root 8 Sep 310:25 2to3 -> 2to3-3.5-rwxr-xr-x 1 root root 109 Sep 310:25 2to3-3.5-rwxr-xr-x 1 root root 250 Sep 310:25 easy_install-3.5
lrwxrwxrwx 1 root root 7 Sep 310:25 idle3 -> idle3.5-rwxr-xr-x 1 root root 107 Sep 310:25 idle3.5-rwxr-xr-x 1 root root 222 Sep 310:25 pip3
- rwxr-xr-x 1 root root 222 Sep 310:25 pip3.5
lrwxrwxrwx 1 root root 8 Sep 310:25 pydoc3 -> pydoc3.5-rwxr-xr-x 1 root root 92 Sep 310:25 pydoc3.5
lrwxrwxrwx 1 root root 9 Sep 310:25 python3 -> python3.5-rwxr-xr-x 2 root root 12334016 Sep 310:25 python3.5
lrwxrwxrwx 1 root root 17 Sep 310:25 python3.5-config -> python3.5m-config
- rwxr-xr-x 2 root root 12334016 Sep 310:25 python3.5m
- rwxr-xr-x 1 root root 3088 Sep 310:25 python3.5m-config
lrwxrwxrwx 1 root root 16 Sep 310:25 python3-config -> python3.5-config
lrwxrwxrwx 1 root root 10 Sep 310:25 pyvenv -> pyvenv-3.5-rwxr-xr-x 1 root root 244 Sep 310:25 pyvenv-3.5[root@10-9-183-29 bin]#
Here you can use the python3
command by configuring environment variables, of course, you can also directly connect the python3
command to the /usr/bin
directory through soft connection
But look at the above output to know
python3
is a soft link of python3.5
pip3 has no soft connection
You can use the python3
command to copy the python3
file directly to the /usr/bin
directory
To use the pip3
command, you can use the method of creating a soft connection
Such as executing the command in the current directory (bin of the installation directory)
cp python3 /usr/bin/
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
This is done
View in the /usr/bin
directory
[ root@10-9-183-29 bin]# ls -l | grep pip
- rwxr-xr-x.1 root root 2291 Jul 312015 lesspipe.sh
lrwxrwxrwx 1 root root 27 Sep 310:39 pip3 ->/usr/local/python3/bin/pip3
[ root@10-9-183-29 bin]# ls -l | grep python
lrwxrwxrwx 1 root root 27 Sep 310:39 pip3 ->/usr/local/python3/bin/pip3
lrwxrwxrwx 1 root root 7 Sep 221:42 python -> python2
lrwxrwxrwx 1 root root 9 Sep 221:42 python2 -> python2.7-rwxr-xr-x 1 root root 7216 Jul 1321:07 python2.7-rwxr-xr-x 1 root root 12334016 Sep 310:37 python3
[ root@10-9-183-29 bin]#
output:
[ root@10-9-183-29 automatic_monitor]# yum install openssl-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
10 gen |2.5 kB 00:00:00
base |3.6 kB 00:00:00
centosplus |3.4 kB 00:00:00
epel |3.2 kB 00:00:00
extras |3.4 kB 00:00:00
updates |3.4 kB 00:00:00(1/2): epel/x86_64/updateinfo |939 kB 00:00:00(2/2): epel/x86_64/primary |3.6 MB 00:00:01
epel 12663/12663
Resolving Dependencies
- - > Running transaction check
- - - > Package openssl-devel.x86_64 1:1.0.2k-12.el7 will be installed
- - > Processing Dependency: zlib-devel(x86-64)forpackage:1:openssl-devel-1.0.2k-12.el7.x86_64
- - > Processing Dependency: krb5-devel(x86-64)forpackage:1:openssl-devel-1.0.2k-12.el7.x86_64
- - > Running transaction check
- - - > Package krb5-devel.x86_64 0:1.15.1-19.el7 will be installed
- - > Processing Dependency:libkadm5(x86-64)=1.15.1-19.el7 forpackage: krb5-devel-1.15.1-19.el7.x86_64
- - > Processing Dependency: libverto-devel forpackage: krb5-devel-1.15.1-19.el7.x86_64
- - > Processing Dependency: libselinux-devel forpackage: krb5-devel-1.15.1-19.el7.x86_64
- - > Processing Dependency: libcom_err-devel forpackage: krb5-devel-1.15.1-19.el7.x86_64
- - > Processing Dependency: keyutils-libs-devel forpackage: krb5-devel-1.15.1-19.el7.x86_64
- - - > Package zlib-devel.x86_64 0:1.2.7-17.el7 will be installed
- - > Running transaction check
- - - > Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
- - - > Package libcom_err-devel.x86_64 0:1.42.9-12.el7_5 will be installed
- - - > Package libkadm5.x86_64 0:1.15.1-19.el7 will be installed
- - - > Package libselinux-devel.x86_64 0:2.5-12.el7 will be installed
- - > Processing Dependency: libsepol-devel(x86-64)>=2.5-6forpackage: libselinux-devel-2.5-12.el7.x86_64
- - > Processing Dependency:pkgconfig(libsepol)forpackage: libselinux-devel-2.5-12.el7.x86_64
- - > Processing Dependency:pkgconfig(libpcre)forpackage: libselinux-devel-2.5-12.el7.x86_64
- - - > Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
- - > Running transaction check
- - - > Package libsepol-devel.x86_64 0:2.5-8.1.el7 will be installed
- - - > Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
- - > Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
openssl-devel x86_64 1:1.0.2k-12.el7 base 1.5 M
Installing for dependencies:
keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k
krb5-devel x86_64 1.15.1-19.el7 updates 269 k
libcom_err-devel x86_64 1.42.9-12.el7_5 updates 31 k
libkadm5 x86_64 1.15.1-19.el7 updates 175 k
libselinux-devel x86_64 2.5-12.el7 base 186 k
libsepol-devel x86_64 2.5-8.1.el7 base 77 k
libverto-devel x86_64 0.2.5-4.el7 base 12 k
pcre-devel x86_64 8.32-17.el7 base 480 k
zlib-devel x86_64 1.2.7-17.el7 base 50 k
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 1Package(+9 Dependent packages)
Total download size:2.8 M
Installed size:6.0 M
Is this ok [y/d/N]: y
Downloading packages:(1/10): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm |37 kB 00:00:00(2/10): libcom_err-devel-1.42.9-12.el7_5.x86_64.rpm |31 kB 00:00:00(3/10): krb5-devel-1.15.1-19.el7.x86_64.rpm |269 kB 00:00:00(4/10): libkadm5-1.15.1-19.el7.x86_64.rpm |175 kB 00:00:00(5/10): libselinux-devel-2.5-12.el7.x86_64.rpm |186 kB 00:00:00(6/10): libverto-devel-0.2.5-4.el7.x86_64.rpm |12 kB 00:00:00(7/10): libsepol-devel-2.5-8.1.el7.x86_64.rpm |77 kB 00:00:00(8/10): openssl-devel-1.0.2k-12.el7.x86_64.rpm |1.5 MB 00:00:00(9/10): zlib-devel-1.2.7-17.el7.x86_64.rpm |50 kB 00:00:00(10/10): pcre-devel-8.32-17.el7.x86_64.rpm |480 kB 00:00:00------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 11 MB/s |2.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64 1/10
Installing : libcom_err-devel-1.42.9-12.el7_5.x86_64 2/10
Installing : libkadm5-1.15.1-19.el7.x86_64 3/10
Installing : libsepol-devel-2.5-8.1.el7.x86_64 4/10
Installing : pcre-devel-8.32-17.el7.x86_64 5/10
Installing : libselinux-devel-2.5-12.el7.x86_64 6/10
Installing : libverto-devel-0.2.5-4.el7.x86_64 7/10
Installing : krb5-devel-1.15.1-19.el7.x86_64 8/10
Installing : zlib-devel-1.2.7-17.el7.x86_64 9/10
Installing :1:openssl-devel-1.0.2k-12.el7.x86_64 10/10
Verifying : krb5-devel-1.15.1-19.el7.x86_64 1/10
Verifying : zlib-devel-1.2.7-17.el7.x86_64 2/10
Verifying :1:openssl-devel-1.0.2k-12.el7.x86_64 3/10
Verifying : libverto-devel-0.2.5-4.el7.x86_64 4/10
Verifying : libselinux-devel-2.5-12.el7.x86_64 5/10
Verifying : pcre-devel-8.32-17.el7.x86_64 6/10
Verifying : libsepol-devel-2.5-8.1.el7.x86_64 7/10
Verifying : libkadm5-1.15.1-19.el7.x86_64 8/10
Verifying : libcom_err-devel-1.42.9-12.el7_5.x86_64 9/10
Verifying : keyutils-libs-devel-1.5.8-3.el7.x86_64 10/10
Installed:
openssl-devel.x86_64 1:1.0.2k-12.el7
Dependency Installed:
keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-19.el7 libcom_err-devel.x86_64 0:1.42.9-12.el7_5 libkadm5.x86_64 0:1.15.1-19.el7 libselinux-devel.x86_64 0:2.5-12.el7 libsepol-devel.x86_64 0:2.5-8.1.el7 libverto-devel.x86_64 0:0.2.5-4.el7
pcre-devel.x86_64 0:8.32-17.el7 zlib-devel.x86_64 0:1.2.7-17.el7
Complete![root@10-9-183-29 automatic_monitor]# yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package zlib-devel-1.2.7-17.el7.x86_64 already installed and latest version
Package sqlite-3.7.17-8.el7.x86_64 already installed and latest version
Package 1:openssl-devel-1.0.2k-12.el7.x86_64 already installed and latest version
Resolving Dependencies
- - > Running transaction check
- - - > Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed
- - - > Package sqlite-devel.x86_64 0:3.7.17-8.el7 will be installed
- - > Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
bzip2-devel x86_64 1.0.6-13.el7 base 218 k
sqlite-devel x86_64 3.7.17-8.el7 base 104 k
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 2 Packages
Total download size:322 k
Installed size:748 k
Is this ok [y/d/N]: y
Downloading packages:(1/2): bzip2-devel-1.0.6-13.el7.x86_64.rpm |218 kB 00:00:00(2/2): sqlite-devel-3.7.17-8.el7.x86_64.rpm |104 kB 00:00:00------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.3 MB/s |322 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : sqlite-devel-3.7.17-8.el7.x86_64 1/2
Installing : bzip2-devel-1.0.6-13.el7.x86_64 2/2
Verifying : bzip2-devel-1.0.6-13.el7.x86_64 1/2
Verifying : sqlite-devel-3.7.17-8.el7.x86_64 2/2
Installed:
bzip2-devel.x86_64 0:1.0.6-13.el7 sqlite-devel.x86_64 0:3.7.17-8.el7
Complete![root@10-9-183-29 automatic_monitor]#
The article comes from WeChat public account: Programmer product
Recommended Posts