Want a surefire way to throw your computer across the room because of your skyrocketing frustration after accomplishing absolutely nothing for a few hours (or days)? 

If teaching your cat to dodge computer parts as you get frustrated and throw them around the room sounds like fun, then code without a virtual environment.

If not, keep reading below on how to set up your virtual environment and avoid hours of frustration (while keeping your cat safe from you throwing your computer against the wall). 

We'll go over exactly why you need a virtual environment in this email, so read all the way to the bottom, please.

In the last two emails, we've been talking about how frustrating it can be when you're trying to solve an OpenCV or deep learning problem on your own.

We even told you a few stories about people who tried to "YouTube" their way through learning and problem-solving. 

The results weren't that great. 

We also explored relaxation and how brain states impact learning. What we discovered was that to learn, you need to be relaxed.

"You can only make good music in the relaxed state." —Rick Sanchez

What would you think if I told you that you could relax, learn, and train your first model in one hour or less?

Imagine how great it would feel to quickly create a virtual environment on your computer to have the right development environment and speed up your development.

A virtual environment is critical because it lets you isolate your development environment from the rest of your computer. You can even have multiple virtual environments, each with a custom version of the libraries you need.

It's a massive time saver and will keep you from getting frustrated by complicated code dependencies.

You would be certain that your environment would work each and every time you went to use it. No more error messages and broken code.

Then, with your virtual environment powering along at full efficiency, you could sit down and master OpenCV basics, allowing you to create your first OpenCV project.

30 minutes after you first touch your keyboard, you can see a real OpenCV project powered by deep learning come to life.

Imagine being able to share the code output with your coworkers, friends, or family the same day you start a project. You can showcase your skills and the power of OpenCV and feel proud and confident that you use OpenCV to solve real-world problems.

Remember, this is all in one day.

Then, imagine you want to work on some Convolutional Neural Networks (CNNs) to buff up your deep learning skills, so you power up another virtual environment and train your first CNN using TensorFlow, Keras, or PyTorch.

Maybe you want to share this same project, so you transfer it quickly and easily to a Colab Notebook to make sharing, experimentation, and visualization even easier.

Stay tuned, and we'll help you achieve everything we've discussed.

But to get you started, let's talk about something you can do right now. Something that's simple but powerful.

Let's build your first virtual environment: Source

First, create a virtual environment which is

  python3 -m venv /path/to/new/virtual/environment

Then, you need to activate the virtual environment using a script in the correct binary directory.

Platform Shell Command to activate virtual environment
POSIX
bash/zsh
$ source /bin/activate 
  fish $ source /bin/activate.fish
 
csh/tcsh
$ source /bin/activate.csh
  PowerShell Core $ /bin/Activate.ps1
Windows cmd.exe C:gt; <venv>\Scripts\activate.bat
  PowerShell PS C:gt; \Scripts\Activate.ps1

Be sure to replace <venv> with the path of the correct directory.

You can now launch your virtual environment by using "workon" and the virtual environment name.

If you need more resources, be sure to check out the venv docs or our blog post.

While that gets you one step closer to being able to complete an OpenCV or deep learning project, we know it's not everything you need.

Don't worry, though. We have some massive things in the works to accelerate your projects, prototypes, and learning. We think it will change the landscape of OpenCV and deep learning.

All you need to do is stay tuned for more information in the next few days.

We hope you are as excited as we are!

PyImageSearch Team

Not interested?  Cool, opt out of this sale.