====== Python Development Environment ====== Raspbian comes with both Python 2 and 3 IDLE installed, they can be accessed through the top bar **Menu > Programming > Python 2/3 (IDLE)** To create a new Python file in IDLE, use the **File > New File** menu.\\ Write some Python code and **File > Save**.\\ Then run your script with **Run > Run Module (F5)**. You can [[https://www.raspberrypi.org/documentation/usage/python/more.md|read more about Python on the Pi here]]... ===== Virtual Environments ===== In order to create multiple isolated Python environments we can use [[http://pypi.python.org/pypi/virtualenv|virtualenv]]. An explanation on using virtualenv is available on the [[http://docs.python-guide.org/en/latest/dev/virtualenvs/|Python guide website]]. We first need to globaly install virtualenv from pip: <code> > sudo pip install virtualenv </code> Then create a project folder and create a corresponding virtual environment: <code> > cd ~/path/to/my-project/ > virtualenv venv [> virtualenv -p /usr/bin/python3 venv] # to use a specific Python interpreter </code> Now that our virtual environment is created, we need to activate it: <code> [> cd /path/to/my-project] > source venv/bin/activate </code> The name of the current virtual environment will now appear on the left of the prompt: <code> > (venv) pi@raspberrypi: ... </code> From that point, any package that we install using pip will be placed in the venv folder, isolated from the global Python installation. Like this: <code> > pip install requests </code> Once we are done working in the virtual environment, we deactivate it: <code> > deactivate </code>