天天看點

Kali 2018.1編譯安裝Python3.7

1.1 下載下傳Python-3.7源碼包

[email protected]:/home# python -V
Python 2.7.14+
[email protected]:/home# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
           

1.2 解壓安裝

[email protected]:/home# ls -l
total 22224
-rw-r--r-- 1 root root 22745726 Jun 27 14:06 Python-3.7.0.tgz
[email protected]:/home# tar -zxvf Python-3.7.0.tgz 
[email protected]:/home# mkdir /usr/local/Python-3.7
[email protected]:/home# cd Python-3.7.0/
[email protected]:/home/Python-3.7.0# ./configure --enable-optimizations --prefix=/usr/local/python3.7/
[email protected]:/home/Python-3.7.0# make && make install
           

1.3 安裝報錯,安裝依賴包繼續

Kali 2018.1編譯安裝Python3.7
## 安裝依賴包
[email protected]:/home# 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
## 如果報錯,删除鎖檔案,繼續執行安裝
## [email protected]:/home/Python-3.7.0# rm /var/cache/apt/archives/lock 
## 繼續編譯安裝
[email protected]:/home/Python-3.7.0# make install
	......
	......
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
           

1.4 安裝完成,測試

[email protected]:/home# python -V
Python 2.7.14+
[email protected]:/# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 9月  26 10:46 /usr/bin/python -> python2.7
[email protected]:/# ln -s -b /usr/local/python3.7/bin/python3.7 /usr/bin/python 
[email protected]:/# python
Python 3.7.0 (default, Sep 26 2018, 12:17:46) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world')
hello world
>>> exit()