Installing a Python virtual environment

We will be using virtualenv  and virtualenvwrapper 

Next we will be installing a virtual environment on the PI to help keep dependencies and projects separated. Keeping Python separated in independent environments should help you in the future by ensuring that it is well isolated. Go ahead and run the following commands below.

 

Now that both virtualenv  and virtualenvwrapper  are installed, we need to update our ~/.profile  file so that it include’s the following lines at the very bottom of that file:

Now that the ~/.profile is updated, we will reload it to verify the changes. Try and force a reload of your ~/.profile  file using the instructions below:

First attempt logging out and back in to the GUI. You can also try closing out the terminal and open up a brand new one

Or you can simply use the source  command seen below:

1
$ source ~/.profile

Helpful Note: I recommend running the source ~/. command when you first load into the Pi so you have the correct dependencies for your computer vision projects. 

Create your Python virtual environment

Next we will use a Python virtual environment that will be used for computer vision projects: Below is for Python 2.7

Making sure your in the “cv” virtual environment.

If you ever restart your Raspberry Pi; log out and log back in; or open up a new terminal, Please use the workon command to re-access the “cv” virtual environment.

Now simply use the workon command and you will be in the “cv” virtual environment:

Always do a check to see that you are in the “cv” virtual environment, if you don’t see the cv on the prompt try running the above command over again.

 

Head back to installing OpenCV.