ubuntu install Python3.7

A source installation:

1. Download the official website Source:

Python's official website: HTTPS: // www.python.org/downloads/ 
setuptools official website: HTTPS: // pypi.org/project/setuptools/#files 
PIP official website to download: HTTPS: // pypi.org/project/pip/#files

2. Start the installation Python3.7

(1) Installation encoding steps: Configuration (configure), compiling (make), the installation (make install)

(2) extracting: sudo tar -zxvf Python-3.7.4.tgz

(3) mounted reliance: $ sudo apt-get install libffi-dev

NOTE: In 3.7, ctypes module dependencies libffi-dev If not, the installation being given:. ModuleNotFoundError: No module named '_ctypes'

(4) Configuration:

$ cd Python-3.7.4
$ ./configure --prefix=/opt/ptyhon3.7

. (5) compile:

$ sudo make

. (6) Installation:

$ sudo make install

(7) Use the update-alternatives to create a soft link

$ sudo update-alternatives --install /opt/python3.7/bin/python python /usr/bin/python3.7 100

(8). Select the version of Python

$ sudo update-alternatives --config python

(9) View success

$ Python -V

(10) Delete junk files

$ sudo rm -rf Python-3.7.4.tgz
$ sudo rm -rf python-3.7.4

3. Install pip

Description: 
( 1 .) I have been installed on / under opt, basically requires administrator privileges. 
( 2 ) Because I want pip and python3. 7 linked together, so run setup.py is run by python3.7. 
( 3 ). This installation comprising pip pip and the pip3, pip is used to install third-party modules.

(1) Install

Before installing pip, you need to install the setuptools 

the sudo the unzip the setuptools - 40.6 . 2 .zip 
CD the setuptools - 40.6 . 2 
. The sudo to python3 . 7 setup.py Build 
. The sudo to python3 . 7 setup.py the install
Pip an_zhuang 

The sudo tar zxvf pip 18.1 The targz 
cd followed by pip - 18.1 The 
The sudo python3. 7 And setuppy build 
The sudo python3. 7 And setuppy install

(2). To see if the installation was successful

See version information pip, you can see the final brackets are bound to the version. If you want to use the convenient, you can create a soft link.

(3) .pip create a soft link

$ sudo ln -s /opt/ptyhon3.7/bin/pip3 /usr/local/bin/python3.7

II. About virtualenv virtual environment python version

1. Create a virtual environment Python3.7

virtualenv -p /opt/ptyhon/python3.6.4/bin/python venv_c

Guess you like

Origin www.cnblogs.com/rixian/p/11332615.html