Describe how to install python2.7.9 in 64-bit ubuntu14.10 system

Source: Internet
Author: User
Tags virtualenv

In ubuntu14.10, python2.7.8 and python3.4.2 are installed by default. They can be found under/usr/bin/. By default, python2.7.8 is used.

Xx @ ada :~ $ Python -- version
Python 2.7.8
Xx @ ada :~ $ Python3.4 -- version
Python 3.4.2
Xx @ ada :~ $ Python2.7 -- version
Python 2.7.8
Xx @ ada :~ $ Which python
/Usr/bin/python
Xx @ ada :~ $ Which python3.4
/Usr/bin/python3.4
Xx @ ada :~ $

Now python official website has the python2.7 series of python2.7.9. Now, we are trying to install python2.7.9.

Python has several installation methods in ubuntu:

Install it through the official apt toolkit of ubuntu
Use the apt toolkit of PPA (Personal Package Archive) to install
Install python by compiling python source code

Install it through the official apt toolkit of ubuntu

Sudo apt-get install python2.7
Sudo apt-get install python3.4

After the installation is complete, run the following command to confirm

Xx @ ada :~ $ Python2.7 -- version
Python 2.7.8
Xx @ ada :~ $ Python3.4 -- version
Python 3.4.2
Xx @ ada :~ $

Install apt Toolkit from Personal Package Archives

$ Sudo apt-get install python-software-properties
$ Sudo add-apt-repository ppa: fkrull/deadsnkes
$ Sudo apt-get update
$ Sudo apt-get install python2.7

A tool similar to the apt Toolkit for installing python is simple, but sometimes it cannot be installed to the latest version. Therefore, when there are important updates to python, we 'd better learn to directly compile and install python2.7from the source code.

Compile and install python from source code

$ Wget-c https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
$ Tar-xzvf Python-2.7.9.tgz
$ Cd Python-2.7.9/
$ LDFLAGS = "-L/usr/lib/x86_64-linux-gnu"./configure
$ Make
$ Sudo make install

Here, the above wget-c (url) is the download command, the parameter-c indicates that resumable download is supported, and the url is the absolute path of the target file download

The x86_64-linux-gnu in "-L/usr/lib/x86_64-linux-gnu" can be found under/usr/lib/, which is x86_64 can be seen that my system is 64, enter your own system.

After the installation is complete, check that the terminal type python -- version, press enter, and then type which python.

Xx @ ada :~ $ Python -- version
Python 2.7.9
Xx @ ada :~ $ Which python
/Usr/local/bin/python
Xx @ ada :~ $

It can be seen that python2.7.9 is successfully installed, and our default python version is changed to python2.7.9. This is because the operating system searches for commands in sequence according to the PATH environment variables,

Python under/usr/local/bin/is preferentially searched for in/usr/bin/and used as the default python version.

So I have three versions of python under ubuntu14.10, namely python2.7.8, python2.7.9, and python3.4.2, as follows:

Xx @ ada :~ $ Python -- version
Python 2.7.9
Xx @ ada :~ $ Python2.7 -- version
Python 2.7.9
Xx @ ada :~ $ Python3.4 -- version
Python 3.4.2
Xx @ ada :~ $ Python2.7
Python 2.7.9 (default, Jan 3 2015, 03:27:08)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Exit ()
Xx @ ada :~ $

Of course, you can also specify the python path to view the python version, as shown below:

Xx @ ada :~ $/Usr/bin/python -- version
Python 2.7.8
Xx @ ada :~ $/Usr/bin/python2.7 -- version
Python 2.7.8
Xx @ ada :~ $/Usr/bin/python3.4 -- version
Python 3.4.2
Xx @ ada :~ $/Usr/local/bin/python -- version
Python 2.7.9
Xx @ ada :~ $/Usr/local/bin/python2.7 -- version
Python 2.7.9
Xx @ ada :~ $

Now, we have introduced three methods for installing python in ubuntu.

OK, Enjoy it !!!

Since I installed the virtual runtime environment virtualenv and virtualenvwrapper before python2.7.9, the default python version has changed after python2.7.9 is installed, so when I open the terminal again, the following information appears:

/Usr/local/bin/python: No module named virtualenvwrapper
Virtualenvwrapper. sh: There was a problem running the initialization hooks.
 
If Python cocould not import the module virtualenvwrapper. hook_loader,
Check that virtualenvwrapper has been installed
VIRTUALENVWRAPPER_PYTHON =/usr/local/bin/python and that PATH is
Set properly.
Xx @ ada :~ $

From the above information, we can know that the new installation directory of python2.7.9 cannot find the module virtualenvwrapper, but they are still available. Try the following commands on the terminal:

$ Virtualenv -- help

$ Mkivrtulaenv -- help

$ Workon

/Usr/local/bin/python: No module named virtualenvwrapper
Virtualenvwrapper. sh: There was a problem running the initialization hooks.
 
If Python cocould not import the module virtualenvwrapper. hook_loader,
Check that virtualenvwrapper has been installed
VIRTUALENVWRAPPER_PYTHON =/usr/local/bin/python and that PATH is
Set properly.
Xx @ ada :~ $ Workon
Env
Xx @ ada :~ $ Workon env
/Usr/local/bin/python: No module named virtualenvwrapper
/Usr/local/bin/python: No module named virtualenvwrapper
(Env) xx @ ada :~ $ Deactivate
/Usr/local/bin/python: No module named virtualenvwrapper
/Usr/local/bin/python: No module named virtualenvwrapper
Xx @ ada :~ $

This does not affect the virtual running environment. But every time I open the terminal, I see the information. I am currently trying to find a solution...

Enter pip freeze to check the installed python module:


Xx @ ada :~ $ Pip freeze
Adium-theme-ubuntu = 0.3.4
Apt-xapian-index = 0.46
Ccsm = 0.9.12
Characteristic = 0.1.0
Chardet = 2.2.1
Colorama = 0.3.1
Command-not-found = 0.3
Compizconfig-python = 0.9.12
Debtagshw = 0.1
Defer = 1.0.6
Dirspec = 13.10
Duplicity = 0.6.23
Gevent = 1.0.1
Greenlet = 0.4.5
Html5lib = 0.999
Httplib2 = 0.9
Idna = 0.9
Lockfile = 0.8
Lxml = 3.3.6
Oauthlib = 0.6.1
Oneconf = 0.3.7
PAM = 0.4.2
Pbr = 0.10.7
Pexpect = 3.2
Pillow = 2.6.1
Piston-mini-client = 0.7.5
Pyasn1 = 0.1.7
Pyasn1-modules = 0.0.5
Pycrypto = 2.6.1
Pycups = 1.9.67
Pycurl = 7.19.5
Pygobject = 3.14.0
PyOpenSSL = 0.13.1
Pyserial = 2.6
Python-apt = 0.9.3.10ubuntu1
Python-debian = 0.1.22
Pyxdg = 0.25
Reportlab = 3.1.8
Requests = 2.3.0
Service-identity = 1.0.0
Sessioninstaller = 0.0.0
Six = 1.7.3
Software-center-aptd-plugins = 0.0.0
Stevedore = 1.1.0
System-service = 0.1.6
Twisted-Core = 14.0.2
Twisted-Web = 14.0.2
Unity-lens-photos = 1.0
Urllib3 = 1.8.3
Virtualenv = 12.0.4
Virtualenv-clone = 0.2.5
Virtualenvwrapper = 4.3.1
Wheel = 0.24.0
Xdiagnose = 3.6.6
Zope. interface = 4.1.1
Xx @ ada :~ $


Now, your python2.7.9 has been installed on the 64-bit ubuntu14.10 system. Is it easier than you think.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.