Centos7+python+virtualenv+virtualenvwrapper Environment Installation

Source: Internet
Author: User

First, Python upgrade to the latest version (2.7.10)

1. Check the Python environment

[Root@vice ~]# python

Python 2.7.5 (default, June 17 2014, 18:11:42)

[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>>

2, upgrade Python to the latest version 2.7.10

Download python-2.7.10.tgz to TMP directory

TAR-ZXVF python-2.7.10.tgz

CD Python-2.7.10

./configure--prefix=/usr/local/python2.7
Make
Make install

After installation, run the Python to see if it's normal.

[Root@vice bin]#/usr/local/python2.7.10/bin/python2.7-v

Python 2.7.10

Next you need to create a link to make the system default Python into python2.7.10.
Ln-fs/usr/local/python2.7.10/bin/python2.7/usr/bin/python
Run Python view version

[Root@vice bin]# Python-v

Python 2.7.10

3. After making changes, Yum will not be able to run. Modify the/usr/bin/yum file

Vim/usr/bin/yum

The first line of the
The Python version in #!/usr/bin/python is replaced with the Python versions that I installed, as follows:
#!/usr/bin/python2.7

[Root@vice bin]# Yum

Loaded plugins: Fastestmirror

You need to give the command

Usage:yum [Options] COMMAND

Indicates that the Python update was successful

Second, install Setuptools, install PIP

Download ez_setup.py

Python ez_setup.py Install

After installation, run easy_install .

[Root@vice tmp]# Easy_install

Traceback (most recent):

File "/usr/bin/easy_install", line 5, <module>

From pkg_resources import Load_entry_point

File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3074, in <module>

File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3060, in _call_aside

File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3087, in _initialize_master_working_set

File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 647, in _build_master

File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 660, in _build_from_requirements

File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 833, in resolve

Pkg_resources. Distributionnotfound:the ' setuptools==0.9.8 ' distribution was not found and are required by the application

The command is found to be error-run. Re-install Python distribution-0.6.49 (0.7.3 will error)

Download distribution link https://pypi.python.org/pypi/distribute/0.6.49

TAR-ZXVF distribute-0.6.49.tar.gz

CD distribute-0.6.49

Python setup.py Install

Install PIP after installation

Easy_install pip

Third, installation of virtualenv and Virtualenvwrapper

pip install-y virtualenv virtualenvwrapper

Tip pip to find the command

OK, let's do this ( because you need to configure the environment variable, or you can't find the PIP)

/usr/local/python2.7/bin/pip Install Virtualenv

/usr/local/python2.7/bin/pip Install virtualenvwrapper

IV. Configuring environment variables

Vim/etc/profile

At the end, add the following:

python_home=/usr/local/python2.7/bin/

Workon_home = $HOME /. Virtualenvs # where all the virtual environments are placed

Project_home = $HOME / Dev # put all the items in place

Export path= $PATH: $PYTHON _home: $WORKON _home: $PROJECT _home

Save exit

Source /usr/local/python2.7/bin / Virtualenvwrapper . SH


Create a virtual environment

Mkvirtualenv Demo1

    • workonSwitch to Environment

    • deactivateUnregister the current environment

    • lsvirtualenvList all environments

    • rmvirtualenvDelete an environment

    • cpvirtualenvReplication environment

    • cdsitepackagesCD to the directory of the current environment site-packages

    • lssitepackagesList content in the current environment site-packages

    • setvirtualenvprojectBinding existing projects and environments

    • wipeenvClear all third-party packages in the environment

Appendix:

(Some developers need to use the package, appropriate download installation)

Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ldap Openldap-clients openldap-servers

Yum-y Install vim wget


Centos7+python+virtualenv+virtualenvwrapper Environment Installation

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.