ubuntu12.04 install python3

System environment ubuntu12.04 (32bit)

The default system already comes with python2.7. When installing python3.5, do not delete the python2.7 version, because the system itself has many functions that require python2.7 support. The vitrualenv tool can be used to isolate the environment of different python versions, and it should be possible for different versions of python to coexist. In fact, when installing python3.5, pay attention to configure the installation path and re-establish the soft link to distinguish python2.7 and 3.5. You don't need to use vitrualenv.

This article mainly records the problems and solutions encountered when installing python3.5, pip and setuptools.

Install python3.5:

Log in to the official website of python: https//www.python.org/ to find the source release version for linux.

I am using:

$ cd /usr/local/src
$ wget  https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz  #python3.5.Version 1
$ xz -d Python-3.5.1.tar.xz  #Unzip
$ tar xvf Python-3.5.1.tar  #Unzip
$ cd Pyton-3.5.1
$ sudo mkdir /usr/local/python3
$ sudo chmod 777/usr/local/python3/
$ ./configure --prefix=/usr/local/python3  #Configure python3.5 installation path
$ sudo make   #Compile
$ sudo make install #installation

When compiling make, pay attention to the last printed message, which may be something like this:

Python build finished successfully!
The necessary bits to build these optional modules were not found: 
_ bz2       _curses         _curses_panel      _dbm         _gdbm  
_ lzma       _sqlite3   _ssl      _tkinter     readline     zlib   
                                   
To find the necessary bits, look in setup.py in detect_modules()for the module's name.

Among them, if you are prompted that zlib and _ssl are missing at the end of the compilation, this will affect the installation of pip3 and setuptools later. Therefore, they need to be installed.

Install zlib:

$ sudo apt-get install --reinstall zlibc zlib1g zlib1g-dev

Install _ssl:

$ sudo apt-get install libssl-dev

Then re-make, make install.

The installation should be successful this time, and the final output information is:

Collecting setuptools 
Collecting pip 
Installing collected packages: setuptools, pip 
Successfully installed pip-7.1.2 setuptools-18.2

What we need to do now is to make a soft link between python3.5 and its corresponding pip version, to distinguish it from python2.7.

$ cd  /usr/bin
$ sudo ln -s /usr/local/python3/bin/python /usr/bin/python3  #Personally like the name
$ sudo ln -s /usr/local/python3/bin/pip /usr/bin/pip3
$ python3  --version  #View version
$ pip3   --version  #See that the output path comes from python3.5 is right

supplement:

Starting from the python (>=3.4) version, pip and setuptools will be installed by default. If the python installation environment is incorrect during the installation process, the installation of pip and setuptools may fail. For example, missing modules will be output during make.

Recommended Posts

ubuntu18.04 install python2
ubuntu12.04 install python3
ubuntu18.04 install python
Install python3.6 under Ubuntu 16.04
Install Python3 on Ubuntu 14.04
Install python in Ubuntu
Install Python3 on Ubuntu 16.04
Install Python3.7 on Ubuntu
Ubuntu install the latest Python 3.
ubuntu18.04 compile and install python3.8
Ubuntu16 upgrade Python3
Relearn ubuntu --python3
ubuntu18.04 install docker
Ubuntu install guide
Centos7 install Python2.7
ubuntu install nodejs
ubuntu 16 install asp.net
ubuntu install leanote
How to install Python 3.8 on Ubuntu 18.04
ubuntu install Jenkins
docker install ubuntu
ubuntu install elasticsearch
Install Python virtual environment on Ubuntu 18.04
Centos install Python3
Install TensorFlow (python2.7 version) on Ubuntu
ubuntu16.0.1 install pagoda
CentOS6.8 install python2.7
ubuntu 18.04 install teamviewer
ubuntu install sendmail
ubuntu16.04 upgrade python2
Install the latest Python 3.6 version on Ubuntu
How to install Python2 on Ubuntu20.04 ubuntu/focal64
Use python3 to install third on ubuntu
Ubuntu18.04 switch Python version
Install apache+PHP under Ubuntu
install vscode on ubuntu18
Install node.js under Ubuntu
Install mysql-pytho in Ubuntu
ubuntu install zsh terminal
Install Redis on Ubuntu
Install R4 on ubuntu20
Install nvtop on Ubuntu 18.04
Install postgresql-10 on Ubuntu 18.04
ubuntu configuration python, Red
Install docker on Ubuntu
Ubuntu18.04 install opencv 3.2.0 solution
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Ubuntu16.04 switch python version
Python MySQLd under Ubuntu
Install Docker on ubuntu18.04
Install nodejs10 on Ubuntu16
ubuntu install harbor warehouse
[python] python2 and python3 under ubuntu
Install mysql on Ubuntu 14.04
Ubuntu16.04 install Mongodb tutorial
Install Django on ubuntu
Install Pytorch+CUDA on Ubuntu 16.04
2018-09-11 Install arduino under Ubuntu
Ubuntu18.04 install Asterisk16.10 + FreePBX15.0