Python virtual environment

Python virtual environment let you keep python dependencies local to individual projects. For example, you have a project lives in a folder, and you can make that folder a python virtual environment, where you can install python dependencies/packages that will only be used by this project. The dependencies will only be visible inside this folder as known as the python virtual environment.

Install python virtualenv, this need to be installed if it is not yet installed. Only need to be done once. It is installed globally.

pip install virtualenv

Initialize a python virtual environment. Run this command in your project folder.

virtualenv venv

Pick a version of python that you like to use for the project.

virtualenv -p /usr/bin/python2.7 venv

Start using the python virtual environment.

source venv/bin/activate

Install python packages for the project. In this case, installing the requests package.

pip install requests

Quit python virtual environment.


Search within Codexpedia

Custom Search

Search the entire web

Custom Search