Use virtualenv to build python3 environment in CentOS

Source: Internet
Author: User
Problem Description

Environment: CentOS6.5

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

The previous practice is to install python3 directly from the source, replace the existing development environment, but in the subsequent use of the system found that many scripts rely on python2.6, direct replacement will cause a lot of software is not normal.

Today found a friend use virtualenv build python3 development environment, here record, also convenient I later check.

Installing Python3

The installation script is as follows:

Copy the Code code 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 running 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 system in the/usr/bin/directory. This will lead to a lot of problems and is not easy to handle.

Build PYTHON3 development environment

1, install VIRTUALENV, can be installed through PIP, the command is as follows:

Copy the Code code as follows:


Pip Install Virtualenv

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

Copy the Code code as follows:


Yum Install Python-pip

2. Create a virtual environment:

Copy the Code code as follows:


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

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

3. Activating the Virtual environment:

Copy the Code code as follows:


SOURCE Py34env/bin/activate

3.1. Installing Ipython in a virtual environment

Copy the Code code as follows:


Pip Install Ipython

3.2. Start the Ipython in a virtual environment:

Copy the Code code as follows:


Ipython

4. Exit the virtual environment

Copy the Code code as follows:


Deactivate

The above mentioned is the whole content of this article, I hope you can like.

  • 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.