Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set CONDA_EXE on MS Windows? #38

Open
adrianstaniec opened this issue Aug 4, 2021 · 2 comments
Open

how to set CONDA_EXE on MS Windows? #38

adrianstaniec opened this issue Aug 4, 2021 · 2 comments

Comments

@adrianstaniec
Copy link

where and how exactly should I set this variable on windows

I have already tried:
C:\Users\adrian\Miniconda3\Scripts\conda.exe
/c/Users/adrian/Miniconda3/Scripts/conda.exe

in System Properieties > Environment Variables

and in neovim running
:echo $CONDA_EXE
it shows the set path

but when I try
:CondaChangeEnv
I still get:

RuntimeError: $CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='$CONDA_EXE')

@adrianstaniec adrianstaniec changed the title how to set CONDA_EXE on windows? how to set CONDA_EXE on MS Windows? Aug 4, 2021
@adrianstaniec
Copy link
Author

I looked into the coda and I tried to come up with mimal example,
here output from Window cmd terminal:

C:\Users\adrian>echo %CONDA_EXE%
C:\Users\adrian\Miniconda3\Scripts\conda.exe




C:\Users\adrian>type z.py
from subprocess import check_output, CalledProcessError, PIPE
import json
import os


def vim_conda_runshell(cmd):
    """ Run external shell command """
    return check_output(cmd, shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')

try:
    output = vim_conda_runshell('$CONDA_EXE info --json')
    print(json.loads(output))
except CalledProcessError:
    cmd = vim_conda_runshell('echo $CONDA_EXE').strip()
    raise RuntimeError("$CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='{}')".format(cmd)) from None



C:\Users\adrian>python z.py
Traceback (most recent call last):
  File "C:\Users\320138242\z.py", line 15, in <module>
    raise RuntimeError("$CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='{}')".format(cmd)) from None
RuntimeError: $CONDA_EXE is not set to a valid conda executable ($CONDA_EXE='$CONDA_EXE')

So it seems that it about the difference between syntax of using %CONDA_EXE% vs $CONDA_EXE.

On the other hand if I try the same thing inside Git Bash terminal, I get:

adrian@adriansmachine MINGW64 ~
$ echo $CONDA_EXE
/c/Users/adrian/Miniconda3/Scripts/conda.exe
(base)




adrian@adriansmachine MINGW64 ~
$ python z.py
Traceback (most recent call last):
  File "C:\Users\adrian\z.py", line 11, in <module>
    output = vim_conda_runshell('$CONDA_EXE info --json')
  File "C:\Users\adrian\z.py", line 8, in vim_conda_runshell
    return check_output(cmd, shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')
  File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '$CONDA_EXE info --json' returned non-zero exit status 126.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\adrian\z.py", line 14, in <module>
    cmd = vim_conda_runshell('echo $CONDA_EXE').strip()
  File "C:\Users\adrian\z.py", line 8, in vim_conda_runshell
    return check_output(cmd, shell=True, executable=os.getenv('SHELL'), stdin=PIPE, stderr=PIPE).decode('utf-8')
  File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\adrian\Miniconda3\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'echo $CONDA_EXE' returned non-zero exit status 126.
(base)

@zyjux
Copy link
Contributor

zyjux commented Nov 4, 2022

I've added a pull request (#40) that fixed this for me, by using os.getenv rather than directly referencing $CONDA_EXE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants