Environment: Alibaba Cloud ubuntu 14.04
Versions above Python 3.3 natively support virtual environments through the venv module, which can replace the virtualenv before Python.
The venv module provides support for creating lightweight "virtual environments" that provide isolation from the system Python. Each virtual environment has its own Python binary (allowing for authoring environments with different Python versions), and can have its own set of Python packages.
It should be noted that the environment created with the "venv" command in Python 3.3 does not contain "pip" and you need to install it manually. This bug was fixed in Python 3.4.
Official documentation https://docs.python.org/3/library/venv.html
Ubuntu14.04 comes with python3.4, and also has the source of Alibaba Cloud.
ls /etc/apt/sources.list.d/sources-aliyun*
In order not to disturb the original environment, let's use the Python virtual environment
root@iZbp1a3rrzc8abdw4thdc7Z:/opt# python3 -m venv py3
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
root@iZbp1a3rrzc8abdw4thdc7Z:/opt# apt-get install python3.4-venv (坑)
Create a virtual environment
root@iZbp1a3rrzc8abdw4thdc7Z:/opt# python3 -m venv py3
python3 -m venv /path/to/new/virtual/environment
Activate virtual environment
root@iZbp1a3rrzc8abdw4thdc7Z:/opt# source /opt/py3/bin/activate
(py3) root@iZbp1a3rrzc8abdw4thdc7Z:/opt#
Then you can start working. .
pip3 install django
django-admin startproject mysite
.....
I won't repeat it, you can refer to my previous article https://my.oschina.net/longquan/blog/1590277
This article can be installed as python3+django under ubuntu-. -Ha ha