one. Turn off the default virtual environment "Python-django"
Enter command:
Deactivate
you can modify the. profile file to note that the following line does not allow the default to open "Python-django" the Virtual ring environment
enter the ". Profile" File:
CD ~
Vim. Profile
The following line in the comment file
Source/home/vagrant/python-django/bin/activate
two. First execute the following command:
sudo apt-get install python-software-properties
sudo apt-get install Software-properties-common
sudo Add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo pip install--upgrade virtualenv
three. Install python3.5
sudo apt-get install python3.5
after the installation is successful, the default is installed under the "/usr/bin/" directory
enter "python3.5" to verify python3.5
Four. Installation Virtualenvwrapper can configure "/usr/local/bin/virtualenvwrapper.sh" to ". Profile" files so that each time you execute the source command below
sudo pip install virtualenvwrapper
source/usr/local/bin/virtualenvwrapper.sh
you have to source it before you can generate the ". Virtualenvs" file, which will enable the relevant commands of Virtualenvwrapper to take effect .
Five. Creating a python3.5 Virtual environment
sudo virtualenv-p python3.5 env35
Command Description: Use python3.5 to generate virtual environments Env35
Validation:
validation succeeded. You can configure python3.5 to enter the. profile file by using the default version at system startup :
CD ~
Vim. Profile
at the end of the file add the following line
Source/usr/env35/bin/activate
Some commands:
To Activate a virtual environment:
access to the virtual environment directory, Env35/bin
source./activate
To exit a virtual environment:
Deactivate
To Delete an environment:
Rmvirtualenv Env35
Six. Exceptions that may be encountered:
vagrant@precise64:/usr$ virtualenv-p python3.5 env35 Running virtualenv with interpreter/usr/bin/python3.5 Traceback (m
OST recent call last): File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 2283, in <module> main () File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 938, in main never_download=options.never_download) file "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1039, in Create_environment site_packages=site_packages, Clea r=clear)) file "/usr/lib/python2.7/dist-packages/virtualenv.py", line 1166, in Install_python mkdir (lib_dir) file "/usr/lib/python2.7/dist-packages/virtualenv.py", line 399, in mkdir os.makedirs (path) File/USR/LIB/PYTHON3.5/OS.P
Y ", line 231, in Makedirs makedirs (head, mode, EXIST_OK) File"/usr/lib/python3.5/os.py ", line 231, in Makedirs Makedirs (head, mode, EXIST_OK) File "/usr/lib/python3.5/os.py", line 241, in Makedirs mkdir (name, mode) Permissioner ROR: [Errno] Permission Denied: ' env35 ' vagrant@precise64:/usr$ sudo virtualenv-p python3.5 env35 Running virtualenv with interpreter/usr/bin/p ython3.5 New python executable in env35/bin/python3.5 Also creating executable into Env35/bin/python Failed to import the SI Te module Traceback (most recent call last): File "/usr/env35/lib/python3.5/site.py", line, <module> Imp ORT os File "/usr/env35/lib/python3.5/os.py", line 666, on <module> from _COLLECTIONS_ABC import Mutablemappin G Importerror:no module named ' _collections_abc ' error:the executable env35/bin/python3.5 is not functioning error:it t
Hinks sys.prefix is '/usr ' (should be '/usr/env35 ') error:virtualenv are not compatible with this system or executable
The solution to this anomaly is: Upgrade the virtualenv.
sudo pip install--upgrade virtualenv
You may encounter a situation where a package cannot be found:
One workaround is to configure the source from the new:
Enter the "pip.conf" file, the contents of the file are modified to (that is, with the source of watercress):
[Global]
Index-url = http://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com