Using VIRTUALENV to build python3 environment in CentOS

Source: Internet
Author: User
Tags centos virtual environment virtualenv

Virtualenv can build a virtual, stand-alone Python environment that allows each project environment to be isolated from other projects, keeping the environment clean and resolving package conflict issues. Here we will discuss how to build the next CentOS in detail.

Problem description

Environment: CentOS6.5

You want to use PYTHON3 for development in this environment, but CentOS6.5 the default Python environment is version 2.6.6.

The previous approach is to install Python3 directly from the source code, replace the existing development environment, but in the subsequent use of the system found that many of the scripts rely on python2.6, direct replacement can cause many software is not normal.

Today found a friend to use VIRTUALENV to build python3 development environment, here recorded, but also convenient for me to consult later.

Install Python3

The installation script is as follows:

The code is as follows:

wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz

Tar zxvf python-3.4.3.tgz

CD Python-3.4.3

./configure--prefix=/usr/local

Make && make Altinstall

After you run the above command, you can see the newly compiled environment in the directory/usr/local/bin/python3.4.

Note: Here we are using make altinstall, and if you use makes install, you will see that there are two different versions of Python in the/usr/bin/directory in the system. This can lead to a lot of problems and is difficult to deal with.

Build PYTHON3 development environment

1, installation virtualenv, can be installed through the PIP, the order is as follows:

The code is as follows:

Pip Install Virtualenv

If you do not have the PIP installed, you can install it by using the following command:

The code is as follows:

Yum Install Python-pip

2. Create Virtual Environment:

The code is as follows:

Virtualenv-p/usr/local/bin/python3.4 py34env

After the above command is executed, the Py34env folder is created in the current directory, which is the virtual environment that we created.

3. Activate the virtual environment:

The code is as follows:

SOURCE Py34env/bin/activate

3.1, install the Ipython in the virtual environment

The code is as follows:

Pip Install Ipython

3.2, in the virtual environment to start Ipython:

The code is as follows:

Ipython

4, exit the virtual environment

The code is as follows:

Deactivate

The above mentioned is the entire content of this article, I hope you can enjoy.

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.