#Anaconda – How to List and Remove Virtual Environments (get back some disk space!)

Buy Me A Coffee

Hi !

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

conda -V

To show your virtual environments, you must use the command

conda info --envs
anaconda display version and virtual environments
Anaconda PowerShell display conda version and virtual environments

Before deleting any of this, I checked them and … they use some space.

anaconda virtual environments disk size

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

conda env remove --name drone02
conda env remove --name telloOpenCV
conda env remove --name tfenv

And, after this I get some space back to my disk!

Happy coding!

Greetings

El Bruno


References

#Hololens2 – Project sizes using #MRTK

Buy Me A Coffee

Hi !

Quick post today. When I started with Hololens 1, Unity and the Hololens Toolkit a couple of years ago, I did this exercise to have a sense of the required disk space for my projects and tests.

I realize that I didn’t blogged this, so here is an updated version using the latest versions. Here are the tools and versions I’m using:

  • MRTK 2.4
  • Unity 2019.4.6f1
  • Visual Studio 2019 Preview (16.7.0)

And using this tools I follow the steps defined in “Initializing your project and deploying your first application” (see references). Let’s take a look at the disk usage.

  • Create an empty 3D project with Unity.
    Disk Size: 49 MB
  • 2. Build the project in Unity.
    Disk Size: 200 MB
  • Import the MRTK 2.4.0 Foundation package in Unity.
    Disk Size: 332 MB
  • Build the project in Unity.
    Disk Size: 668 MB
  • Build the output in Visual Studio 2019 for the HL2.
    Disk Size: 3 GB
  • Apply MRTK Configuration and Settings for a HL2 in Unity and Build.
    Disk Size: 3.10 GB
  • Build the output in Visual Studio 2019 for the HL2.
    Disk Size: 3.68 GB

So, as you can see, a ready-to-go final project will require around 3.5 GBs disk space. Get ready your credit card for a new SSD !

Happy coding!

Greetings

El Bruno


Resources

#Windows10 – Cleaning some disk space, Windows SDK and #dotnetcore installs

Buy Me A Coffee

Hi!

I’m very careful with my disk space, however my C: drive in Windows 10 started to claim about low space. I got 3 disks on my machine, 2 SSDs and a regular one; and I always check to install all my software on my D: drive. So, that’s why running low space on C: was shocking.

So, I did a small check on the apps and contents using a lot of disk and I found 2 main sources

  • Windows 10 SDKs
  • DotNet Core SDKs and Runtimes

Every time a new version of Windows 10 is released, and I build a Windows 10 App, I get a new Windows SDK. Each one is around 2GBs, I got almost 20, so make your numbers.

Windows 10 Settings App and Features Apps sizes

Note: There is a cool feature to find usage space of installed apps by this, out of the box in Windows Settings.

The second one was related to .Net Core. I had a lot of versions installed, and every time I get a new update on Visual Studio 2019, it seems that I’m updating also my .Net Core SDKs. Right now, I only care about .Net Core 3, so it was time to uninstall all the others.

The official documentation ” How to remove the .NET Core Runtime and SDK” (see references) wasn’t very helpful. However, it was a good source to learn more about dotnet command, specially this one:

C:\> dotnet --list-sdks

This command list all the installed SDKs, and with a little of PowerShell scripting I manage to uninstall almost everything. Once I started this path, I also realize that the

$app.Uninstall()

command was not working, so a little search pointed me into an old article from Scott Hanselman, where he did a similar script to remove old .Net Core versions (see references).

The final script is

# get installed dotNet SDKs
$dnSDKs = dotnet listsdks
Write-Host "—————————"
Write-Host "Installed SDKs:"
foreach ($dnSDK in $dnSDKs) {
Write-Host $dnSDK
}
Write-Host "—————————"
foreach ($dnSDK in $dnSDKs) {
# get sdk information
$dnSDKSplit = $dnSDK.Split('[', [System.StringSplitOptions]::RemoveEmptyEntries)
$dnSDKVersion = $dnSDKSplit[0]
$dnSDKPath = $dnSDKSplit[1].replace(']', '')
Write-Host " >> Version = " $dnSDKVersion
Write-Host " >> Path = " $dnSDKPath
# uninstall sdk, all but 3.0
if($dnSDKVersion.StartsWith("3.")) {
Write-Host " Keep Version = " $dnSDKVersion
}
else {
Write-Host " Uninstalling Version = " $dnSDKVersion
$dnAppName = "Microsoft .NET Core SDK – " + $dnSDKVersion
$app = Get-WmiObject Class Win32_Product | Where-Object {
$_.Name -match $dnSDKVersion
}
Write-Host $app.Name
Write-Host $app.IdentifyingNumber
# official not working
# $app.Uninstall()
# test with Hanselman mode
pushd $env:SYSTEMROOT\System32
$app.identifyingnumber |% { Start-Process msiexec wait ArgumentList "/x $_" }
}
}

You can also get the ps1 file directly from GitHub here https://github.com/elbruno/Blog/tree/master/20191016%20Uninstall%20NetCore%20Versions

And a warning, the script will list all the installed dotnet sdks

And then, when the uninstall process start, we will require to confirm each uninstall action. Not very user friendly, but it get the work done!

Final advice is to repair the .Net Core 3 version, just in case something is missing.

Happy coding!

Greetings @ Burlington

El Bruno

References