I already shared how to create Virtual Environments using Anaconda, and also how to create shortcuts to use them directly in Windows Terminal (see references). This task is easy an amazing, however, at some point you may want to clean your environment.
That’s an easy task. I’m currently using Anaconda version 4.8.3. You can check your version with the command
To show your virtual environments, you must use the command
conda info --envs
Before deleting any of this, I checked them and … they use some space.
As you can see in the previous image
drone02, disk size is 2GB
p38, disk size is 1.4 GB
telloOpenCV, disk size is 2.6 GB
tfenv, disk size is 1.76 GB
I didn’t even check the other virtual environments. Right now I’m only using 2 from the total of 6 on the list, so I’ll delete the non used ones.
To delete a virtual environment we must use the command
conda env remove --name ENVIRONMENT
And with a simple command like this, I can remove the unused ones
Windows Terminal (WT) is one of the coolest tools I’ve using in the last couple of years. I’m not an expert, and not even a fan of CLIs, however I assume working with WT is super cool.
Bonus: If you speak Spanish, I shared my own thoughts about this with Juan and Eduard in a podcast episode here.
On top of this, I also use Anaconda a lot. And, now that we can launch and use Anaconda from a PowerShell Prompt, I think I should spend some time trying to figure out how to have Anaconda inside Windows Terminal.
I will assume that you know the basis of Windows Terminal profiles. As a WT user, we can create as many profiles as we want to have different tools available. This is my starting point to use Anaconda and Windows Terminal.
Note: Check References for Donovan Brown post about working with profiles.
Create a new profile to launch Anaconda in Windows Terminal
Let’s go to Windows Terminal Settings to create a new profile for Anaconda. In order to do this, I’ll copy and paste an existing profile, update the Guid and complete the following values.
guid: create and paste a new Guid
name: I defaulted this to Anaconda
commandline: this is the tricky one. So I’ll describe the steps below.
I browse to [C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)] and view the properties for the [Anaconda PowerShell Prompt]. Then copy the Target value and use the value in the commandline element.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
Now I have a new environment named [drone], and I want to have a shortcut in Windows Terminal to open a new tab with this VirtualEnv activated. I copy & paste the definition of the Anaconda profile, used a new Guid, and added, the following command to the end of the line:
conda activate drone
As you can see in the previous image, when I open a new tab for my Drone Virtual Env, I already have it loaded. I also added a [cls] command at the end, so I can start with a clean environment.
Finally, and for reference, this is my current Windows Terminal settings file including the 2 Anaconda profiles.
After sharing a couple of sessions using the Drone and working with the drone camera, a couple of people contacted me with issues while they try to install OpenCV and/or TensorFlow, to be used with Python.
There are plenty of tutorials about this, so I will share a very easy one.
1st step is to install Anaconda (see references). Once Anaconda is installed, let’s launch the Anaconda PowerShell Prompt to install dependencies.
The 2 main commands to install the desired packages are
yesterday post, I created a new virtual environment named [devtf] and in this environment
I’ve installed a lot of tools that I need. Then I tried to launch a jupyter notebook
from this environment, to use this tools and, of course, it didn’t work.
It was time to read and learn how this works. So, when I finally get this I find this amazing article which really explain how this works “Using Virtual Environments in Jupyter Notebook and Python” (see references)
Jupyter Notebook makes sure that the IPython kernel is available, but you have to manually add a kernel with a different version of Python or a virtual environment. First, you need to activate your virtual environment. Next, install ipykernel which provides the IPython kernel for Jupyter. And finally, you can add your virtual environment to Jupyter.
Where “devtf” is the name of the new kernel you want to create. Now, when I launch Jupyter Notebooks, the new kernel is available to be used
When I started to use this new kernel (virtual environment) I realized that I didn’t installed TensorFlow. You know, being happy about this, naming the kernel TF but not installing the core component. And, sure, my notebooks didn’t work.
I went to my terminal / command prompt and installed TensorFlow. Then I only need to restart the Kernel, and everything start working. I added a extra couple of lines in my notebook just to check the TensorFlow and keras versions.
similar errors with another packages, so I pip installed the packages in the
terminal and restart the kernel to have the notebook OK. So, my simple reminder
for myself about how to do this!
This is the 2nd time I get a weird error when I install TensorFlow in my Anaconda distribution. And this is the 2nd time I realize that I’m using the Anaconda version that is preinstalled with Visual Studio. I’m not sure if the spaces in the path affects the creation of environments or it’s something else, however my current and big and amazing solution is:
Install Anaconda again
follow the simple commands in the official Anaconda and TensorFlow doc (see
I’ve write a lot about how to use AI models in C# to perform tasks like Face recognition, speech analysis, and more. During the Chicago CodeCamp, someone ask me about how to perform Face Recognition in Python. I didn’t have any working sample to showcase this, and I failed in try to write a 2 min app. So I added this into my ToDo list.
For this demo I’ll use Anaconda as the base Python distribution and Visual Studio Code as the code editor. There are several packages to perform face detection in Python. I’ll use a mix between OpenCV and Adam Geitgey Face Recognition package to use the camera and detect and recognize faces.
I’ll start by installing some packages to use in python app: dlib, openCV and face_recognition