Installing Python and its common tools

Source: Internet
Author: User

Python in general we use the 2.7 version, can be downloaded in the official https://www.python.org/downloads/, its installation is very simple.
The tar package can be extracted directly after download, configure, make, do install.


It is important to emphasize that after installing Python there is a good chance that the Linux Yum will not work properly.
On the one hand we can change the contents of the Yum executable file, the file location is/usr/bin/yum,


First line #!/usr/bin/python
Change into
#!/usr/bin/python2.4 (python2.6), which is the original python of the system.


Another is to put the new Python executable file ln to/usr/local/bin here, and the rest can be used without changes.
This will not affect the use of Yum and will not affect the use of the new installation version.

If there is a special need, then set the environment variable according to the situation.

Typically we use Python's development tools or VI to edit projects or files. So Python's auto-completion is not very necessary, but I'll simply say it here.


Because I am using MacOS, this auto-completion file is as follows. Other systems can be found on their own.
I put this tab.py file in the/library/python/2.7/site-packages here. The file location is also changed according to the actual situation
Import Rlcompleter
Import ReadLine
Import atexit
Import OS

If ' Libedit ' in readline.__doc__:
Readline.parse_and_bind (' Bind ^i rl_complete ')
Else
Readline.parse_and_bind (' Tab:complete ')


Histfile = Os.path.join (os.environ[' HOME '), '. Pyhist ')


Try
Readline.read_history_file (Histfile)
Except IOError:
Pass


Atexit.register (Readline.write_history_file, Histfile)
Del ReadLine, Rlcompleter, Histfile, OS


tab is also easy to use


[[email protected] ' s Air site-packages]# python
Python 2.7.6 (Default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on Darwin
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import OS
>>> Import Tab
>>> OS.
Display all 234 possibilities? (Y or N)

Next, a Yum-like tool to install third-party python package-easy_insall. Only Yum is used for CentOS, and Eeasy_insall is used by Python.
Easy_install is a command from the Setuptools package developed by the Peak (Python Enterprise application kit), so use Easy_ The install is actually calling Setuptools to complete the installation of the module.


Its easy installation is also very simple, the installation method is as follows.
#yum Install Python-setuptools Python-setuptools-devel
Or
#wget--no-check-certificate Https://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg (Version can be updated on the official website)
#sudo Sh./setuptools-0.6c11-py2.6.egg


Its use is mainly two aspects
Mounting module
#easy_install package-name (e.g. Easy_install Redis)
Module uninstallation
#easy_install-M package-name (e.g. Easy_install-m Redis)

#easy_install-M package name, you can uninstall the package, but also manually delete the legacy files after uninstallation.


Another and Easy_install tool is Pip
Can be downloaded here at Https://pypi.python.org/pypi/pip#downloads
Download and unzip into the directory, Python setup.py install can be installed.


Common is to find and install:
Use Search, install these two parameters.


Add-on will be useful to view information about a library:
#pip Show Jinja2

To view the libraries you have installed:
#pip List


To get an expired library:
#pip List--outdated
#pip Install--upgrade pip This is the upgrade to pip yourself

Easy_install and Pip Although the method is different, but the installation of the package is the same, so generally I use the PIP. The reason is that PIP only presses three keys.

Installing Python and its common tools

Related Article

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.