3

I am using a windows pc with no admin rights. Python is installed but only works in anaconda prompt and not in normal cmd prompt because it is not added to path. Since I have no admin rights I cannot add it.

I have a fairly simple powershell script that runs a bunch of python scripts:

cd mydir
python script1
"script 1 done"
python script2
"finished"

EDIT: Right now, I open anaconda prompt and manually paste the script in and hit enter. Everything works perfect. Is there a way to do that in powershell, i.e. tell powershell to open anaconda prompt (not standard cmd) and paste the script to it.

js2010
  • 23,033
  • 6
  • 64
  • 66
freddy888
  • 956
  • 3
  • 18
  • 39

2 Answers2

1

You can add it to your path yourself, either in powershell:

$env:path += ';C:\ProgramData\Anaconda3'

cd mydir
python script1
"script 1 done"
python script2
"finished"

Or in your windows profile. Either in the Control Panel, or see the "User" form of this: Setting Windows PowerShell environment variables

The shortcut to Anaconda powershell does a lot of things. Somehow you have to reproduce this if you don't want to use it. I'm not an Anaconda user.

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\ProgramData\Anaconda3' "

Maybe put this at the top of your script. It would modify the path as well.

C:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1
conda activate C:\ProgramData\Anaconda3
js2010
  • 23,033
  • 6
  • 64
  • 66
1

Adding !all three! paths fixed the problem for me.

$env:path += ';C:\ProgramData\Anaconda3\' 
$env:path += ';C:\ProgramData\Anaconda3\Scripts\'
$env:path += ';C:\ProgramData\Anaconda3\Library\bin'
freddy888
  • 956
  • 3
  • 18
  • 39