2

I am using Windows Powershell to remote into another computer on the same network by using the following command:

C:\Users\User1>powershell
Copyright (C) Microsoft Corporation. All rights reserved.    

PS C:\Users\User1> Enter-PSSession -ComputerName REMOTECOMPUTER1

After that, I want to activate a conda virtual environment by doing the following:

[REMOTECOMPUTER1]: PS C:\Users\User1\Documents> C:\ProgramData\Anaconda3\condabin\conda activate User1_Env

However, the command above doesn't seem to do anything. The returned prompt doesn't have the virtual environment name in the front.

[REMOTECOMPUTER1]: PS C:\Users\User1\Documents>

To test if the virtual env has been activated, I run a simple python script that imports a package that is installed in the virtual env (but not in the base env), I get an error message saying there is no such module, suggesting that the virtual env has not been activated.

Any suggestions and pointers would be greatly appreciated!

Alex
  • 4,030
  • 8
  • 40
  • 62

1 Answers1

0

It turns out that you need to register a remote configuration on the remote server, and specify that configuration in your Enter-PSSession call.

The -StartupScript in the remote configuration should point to the file that contains your profile settings (with the conda initialize block) on the remote machine. For example this can be %USERPROFILE%\Documents\WinwdowsPowershell\profile.ps1 (but this might differ on your machine).

This answer goes into detail about configuring the PSSessionConfiguration.

Saaru Lindestøkke
  • 2,067
  • 1
  • 25
  • 51