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