Linux to build Python environment steps detailed

Source: Internet
Author: User
Tags virtualenv arch linux

Write a good many years of PHP code, unavoidably some of the boredom, it is time to learn a new language, this is like for men, the woman at home to see a long time, fresh feeling disappeared, naturally want to take a few house concubine, but for the Handong in the danger of me, this dream is destined to be unreachable, or honestly learn to program it, Think I was a good study of Python, but did not stick to it, I hope this can be done.


Gossip don't say, table A table Python installation, operating system for CentOS, because the version of the old, plus already contains Python-2.4.3, so I changed a path installed Python-2.7.5, currently this version is more general:

shell> wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
Shell> Tar zxvf python-2.7.5.tgz
Shell> CD Python-2.7.5
shell>./configure--prefix=/usr/local/python-2.7.5
Shell> make
shell> make Install


Below look at the package management tool, originally popular is setuptools, but now it has been replaced by distribute, in addition, Easy_install has been replaced by Pip, let's see How to install:

shell> wget http://python-distribute.org/distribute_setup.py
Shell>/usr/local/python-2.7.5/bin/python distribute_setup.py
Shell>/usr/local/python-2.7.5/bin/easy_install Pip


Since it is learning to build a python environment, then virtualenv must be installed, to put it simply, it allows us to create several sets of isolated Python runtime environment, specific introduction can refer to Qihoo's article, let us install it:

shell>/usr/local/python-2.7.5/bin/pip Install virtualenv next create a completely separate Python environment foo:

Shell>/usr/local/python-2.7.5/bin/virtualenv Foo again to see how to enter the environment and exit the environment:

Shell> Source Foo/bin/activate
Shell> Deactivate


This environment already contains the PIP, and the program installed through it only exists in its own environment and does not pollute others.

What do you think? It's very easy to use! Can be used better, but with the help of virtualenvwrapper, it can be installed through the PIP, it has made a package for virtualenv, provided some more convenient commands, specific reference to the official documents.

Note: After using virtualenv, there will be multiple Python environments in the system and not the usual default path, so this requires that we do not use absolute paths while writing scripts, but we should use Env to enhance versatility:

#!/usr/bin/env python In addition, the Python environment installed with VIRTUALENV is the same version, if you want to install different versions, you can consider using other applications, such as: Pythonbrew,pyenv,pythonz and so on.

...

I hope to get python early and then fix Perl, plus PHP, to achieve my 3P Albert.


Attention

The configuration parameters used by Arch Linux are:
./configure–enable-shared–with-threads–with-computed-gotos–enable-ipv6–with-valgrind–with-wide-unicode– With-system-expat–with-system-ffi
The Unicode support of Python 3.3 is divided into two, –with-wide-unicode more (but not and should not be as serious a problem as Ruby). –enable-shared seems to be needed for a program that embeds the Python interpreter.

In addition, some versions use make Altinstall and do not overwrite the Python file (only python2.7 with version numbers).

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.