When I launch PowerShell, I want my Python venv to be automatically loaded.
I've searched a few times, but I've never found anything on how to do that - maybe it's unusual that I'm using venv and PowerShell but also don't know how to do basic things in PS.
My issue was probably that I was searching for stuff about venv, when really this is a question about PowerShell.
Start a PowerShell session and run this command to have an empty ps1 file generated which will run whenever you launch PowerShell:
New-item –type file –force $profile
It'll print out the path to where that empty file was created. Go and open it up - you can put something like the following in:
Write-Host "Running C:\Users\Arty\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
Write-Host " activate C:\Users\Arty\arty.venv`n"
. \Users\Arty\arty.venv\Scripts\Activate.ps1
The first two lines are just print statements reminding me of where the script and venv are and why this happens automatically. This will be useful for later when I've forgotten and take the behavior for granted. The last line is the only important one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With