Last active
July 7, 2020 06:07
-
-
Save pldmgg/c84e802bcecd6e4c962f65be5b5d316d to your computer and use it in GitHub Desktop.
Set Anaconda Usage Instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Launch Windows PowerShell 5.1 or PowerShell Core 6.x and download the AnacondaEnv.psm1 Module | |
# to your Downloads folder (or wherever you like) | |
PS C:\Users\zeroadmin> $AnaEnvModuleUrl = "https://github.com/pldmgg/misc-powershell/blob/master/MyModules/AnacondaEnv/AnacondaEnv.psm1" | |
PS C:\Users\zeroadmin> $OutputPath = "$HOME\Downloads\AnacondaEnv.psm1" | |
PS C:\Users\zeroadmin> Invoke-WebRequest -Uri $AnaEnvModuleUrl -OutFile $OutputPath | |
# Import the AnacondaEnv Module | |
PS C:\Users\zeroadmin> Import-Module $OutputPath | |
# Now the following functions are available to you in your current PowerShell Session: Set-AnacondaEnv, Revert-AnacondaEnv | |
# Use the Set-AnacondaEnv function to set your Anaconda Environment | |
# NOTE: Change the Anaconda3 folder location if it's in a different location on your system | |
# IMPORTANT NOTE: Default behavior for this function is NOT to touch System/Machine Path / Environment Variables, however, | |
# if you DO want to update System/Machine Path and Environment Variables, add the '-ChangeMachineEnv' switch | |
PS C:\Users\zeroadmin> $SetAnacondaEnvResult = Set-AnacondaEnv -AnacondaDirectoryPath "C:\ProgramData\Anaconda3" | |
Environment set successfully! | |
# You can review exactly what (if anything) was changed about your environment by exploring | |
# $SetAnacondaEnvResult (or whatever you end up calling the output variable) | |
PS C:\Users\zeroadmin> $SetAnacondaEnvResult | |
SystemPathChanges : {New, Original} | |
PSEnvPathChanges : {New, Original} | |
PYTHONIOENCODING : {New, Original} | |
CONDA_EXE : {New, Original} | |
CONDA_NEW_ENV : {New, Original} | |
CONDA_PS1_BACKUP : {New, Original} | |
PS C:\Users\zeroadmin> $SetAnacondaEnvResult.SystemPathChanges | |
Name Value | |
---- ----- | |
New NoChange | |
Original C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3;C:\Chocolatey;C:\Chocolatey\lib\NuGet.CommandLine.4.1.0\tools;C:\Ch... | |
# If you would like to revert any/all changes made by the Set-AnacondaEnv function, you can use the Revert-AnacondaEnv function. | |
# IMPORTANT NOTE: You MUST use the output variable of the Set-AnacondaEnv with the Revert-AnacondaEnv function. In this example, | |
# that would be $SetAnacondaEnvResult. | |
PS C:\Users\zeroadmin> $RevertAnacondaResult = Revert-AnacondaEnv -SetAnacondaEnvOutput $SetAnacondaEnvResult | |
Reverted environment successfully! | |
PS C:\Users\zeroadmin> $RevertAnaResult | |
Name Value | |
---- ----- | |
SuccessfulReversions {@{AttemptedValue=; CurrentValue=}, @{AttemptedValue=; CurrentValue=}, @{AttemptedValue=; CurrentValue=}, @{AttemptedValue=; ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment