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.