Python virtual environment: Ubuntu16.04

  1. System environment

Ubuntu16.04

  1. Install and configure the virtual environment

Upgrade pip

sudo pip install --upgrade pip

Install virtual environment

sudo pip install virtualenv
sudo pip install virtualenvwrapper

virtualenvwrapper is an extended management package of virtualenv, which can integrate all virtual environments in one directory.

Configure virtual environment

  1. Create virtual environment management directory
sudo mkdir ~/.envs
  1. Open .bashrc
sudo gedit ~/.bashrc
  1. Add the following at the end of .bashrc
export WORKON_HOME=$HOME/.envs  #All virtual environment storage directories
source /usr/local/bin/virtualenvwrapper.sh
  1. Make the configuration effective
source ~/.bashrc
  1. Update configuration file error: No module named virtualenvwrapper

Solution, re-add python-related environment variables:

(Be sure to confirm the Python version that virtualenvwrapper depends on first)

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
  1. Virtual environment operation

  2. Create a virtual environment

env_name is the name of the virtual environment you want to create, which needs to be connected to the Internet

mkvirtualenv env_name
  1. Create a virtual environment of the specified python version
mkvirtualenv -p /usr/bin/python3.6 python36_
mkvirtualenv -p /usr/bin/python2.7 python27_
  1. View all virtual environments installed
workon
  1. Enter the virtual environment
workon env_nam
  1. Exit the virtual environment
deactivate
  1. Delete virtual environment
rmvirtualenv env_nam
  1. Install the Django framework and required third-party packages in the Python environment

Export the installed library to list.txt

pip freeze > list.txt

Import the libraries listed in list.txt to the system

pip install -r list.txt

Recommended Posts

Python virtual environment: Ubuntu16.04
Install Python virtual environment on Ubuntu 18.04
ubuntu sets python2.5 environment variables
ubuntu build python development environment
Centos7 deploys python3 virtual environment
ubuntu offline installation python environment
How to create a Python virtual environment in Ubuntu 14.04
[python] python virtual environment construction & GPU environment
Ubuntu16 upgrade Python3
ubuntu18.04 install python2
Relearn ubuntu --python3
ubuntu12.04 install python3
ubuntu18.04 install python
Python: Virtual Environment-Ubuntu16.04
ubuntu16.04 upgrade python2
Build arm virtual operating environment on Ubuntu
Vagrant quickly builds Ubuntu virtual machine environment
Detailed usage of Python virtual environment venv
Build a python development environment under Ubuntu
Ubuntu18.04 switch Python version
ubuntu configuration python, Red
Python MySQLd under Ubuntu
Ubuntu configuration development environment
[python] python2 and python3 under ubuntu
Ubuntu development environment configuration
Install Python3 on Ubuntu 14.04
Install Python3 environment in a brand new Ubuntu
Ubuntu Touch environment setup
Install python in Ubuntu
Install Python3 on Ubuntu 16.04
Ubuntu18.10 configure Java environment
ubuntu environment deployment project
Install Python3.7 on Ubuntu
Django&MySQL environment deployment under Ubuntu 14.04
Python introduction and environment installation
Install ubuntu on virtual machine
Install python environment under Linux
Install Python 3.7 on Ubuntu 18.04 LTS
ubuntu14.0464 Ros environment install halcon13.01
ubuntu view python installation path
Virtual machine VirtualBox-5.1 install ubuntu16.0.1
ubuntu builds common development environment
Encountered in the process of building a virtual environment in ubuntu
Detailed steps for installing Django under Python 3.6 in Ubuntu 16.04 environment
Ubuntu 18.04.1 build Java environment and HelloWorld
Virtual machine Linux Ubuntu installation tutorial
Deploy JobConverter + Ibreoffice environment on Ubuntu
Ubuntu environment variables and ADB configuration
How does python change the environment
Build an Ubuntu Linux development environment on a Vmware virtual machine
Ubuntu16.04 build php5.6 Web server environment
Docker ubuntu: install python-PIL-image environment on 14.04
How to install Python 3.8 on Ubuntu 18.04
Python Chinese encoding setting under ubuntu
Configure python3 environment on centos7 and
Install TensorFlow (python2.7 version) on Ubuntu
Ubuntu 19.1 installation and configuration Chinese environment
Install Spark stand-alone environment on Spark Ubuntu18
Install Hadoop system environment on Ubuntu 18.04
CentOS 7 configure Python language development environment
Install the latest Python 3.6 version on Ubuntu