"conda: command not found", Bash on Windows - windows

I have installed Bash for windows by activating the Windows Subsystem for Linux and installing Ubuntu and when I installed Anaconda I selected the "Add Anaconda to my PATH environment variable" setting, so I do not believe there are any issues with PATH.
What I see in my Edit environment variables window is:
C:\Users\user\anaconda3
C:\Users\user\anaconda3\Library\mingw-w64\bin
C:\Users\user\anaconda3\Library\usr\bin
C:\Users\user\anaconda3\Library\bin
C:\Users\user\anaconda3\Scripts\
In Bash, when I enter something such as conda info --base I get conda: command not found
However, when I run the same command in Git Bash, it runs just fine.

From within git bash, you can type, command -v conda, as it will output the location to the executable. Add the directory to your PATH environment variable.
Eg from within git bash:
$ command -v my_command
/c/path/to/bin/my_command
Then prefix the value with /mnt and add it all: /mnt/c/path/to/bin to your PATH environment variable. And reopen your bash shell.

you can:
use git-bash / PowerShell / CMD for Anaconda
use Windows Terminal for easily using multiple shells
modify ~/.profile to include the Anaconda folders to PATH. /mnt/c/Users/user/Anaconda3...
NB you may experience issues with file paths or output
in advance, you could check the output of echo "${PATH//:/$'\n'}" | grep -i conda in a new session of bash
because typically, Windows and WSL should have already configured this for you
install Anaconda on WSL following official Linux instructions for your distro
if unsure which distro, it's likely Ubuntu. so instructions for Debian, the parent of Ubuntu
WSL is a complete Linux virtual machine and not your best bet for running (cli) software that you installed on Windows. you can but i would personally prefer installing the Linux version in WSL.

Related

Conda is not recognized as an internal or external command

Command line screen capture
I have successfully installed Anaconda on my drive D and added it to my path so that I am able to access it from cmd without using the Anaconda prompt.
However, after running where conda on the Anaconda prompt, I got the 3 different locations
- D:\Anaconda\Library\bin\conda.bat
- D:\Anaconda\Scripts\conda.exe
- D:\Anaconda\condabin\conda.bat
to set as paths but after doing that, the conda command on my command line still does not work.
From the error image and description of the issue, I can see that you have installed the anaconda in the D:\ drive and tried to access it through the C:\ drive.
To access the conda in command prompt, you need to run the below commands :
C:\Users\Loni Tande>cd D:\Anaconda\Scripts
D:\Anaconda\Scripts>conda
D:\Anaconda\Scripts>conda --version
Please make sure you have the latest Anaconda version installed in your system to access all its functionalities.

What is the syntax for invoking "conda run" from an Anaconda installation on Windows?

I've installed Anaconda on a Windows 7 machine using this installer: Anaconda3-2019.03-Windows-x86_64.exe. If I run '"C:/Program Files/InstallDir/Scripts/conda.exe" run --help' from a cmd window I get the help text for 'conda run' that shows the example usage:
Example usage:
$ conda create -y -n my-python-2-env python=2
$ conda run -n my-python-2-env python --version
However, if I try '"C:/Program Files/InstallDir/Scripts/conda.exe" run -n base python -c print('hi')' the executable just hangs with no output until I terminate it with Cntr-C.
What is the proper syntax to use 'conda run' from an Anaconda install without PATH modification on Windows?
I discovered that the reason that I was unable to get "conda run" to work is because some temp file is created in the Anaconda installation directory when this command is run. Because I had installed Anaconda to a system folder (i.e. in C:\Program Files\InstallDir), when conda attempted to create the temp file it was not able to.
When I ran a console window as an administrator, I was able to use the following syntax successfully: "C:/Program Files/InstallDir/Scripts/conda" run -n base -v python "C:/Users/someuser/Desktop/somescript.py".
I'll consider this thread closed and post a related question about how to invoke "conda run" from an system directory without being an administrator.

Conda commands not working in Windows Subsystem for Linux (WSL)

I installed Anaconda3 in my windows environment and added
C:\Users\user\Anaconda3\Scripts
C:\Users\user\Anaconda3
to my windows environmental variables. Theoretically, this should also update my path in WSL like it does with visual studio code. However it didn't and now I can't run conda commands from the ubuntu terminal. I can't figure out how to fix this...thanks!
*It should be noted that I am also using zsh and oh my zsh by running the code
# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi
Inside my bashrc file
I had a similar problem. The issue was, that I had installed conda for windows and it seems it doesn't run fine with wsl. Try downloading and installing conda for ubuntu from the wsl command line interface and add the folders to the path. It worked for me.
This link helped me download conda from wsl command life interface.
If path not added, export PATH="/Users/username/anaconda/bin:$PATH" to your .zsh_config file.
This link may help you
Zsh: Conda/Pip installs command not found

How to set the default python interpreter to Anaconda2 path, rather than usr/bin/ default in WSL

Is there a way to change the PATH variable from the default in WSL (/user/bin) to the Anaconda2 path in in C drive in windows.
This is similar to this question: Python, change interpreter what use system. From anaconda2/bin/python2.7 to /usr/bin/pyhon2.7 , but I think that user has his Anaconda installed after his WSL installation, in WSL. I'm trying to redirect my python interpreter in bash from the WSL usr/bin to the Anaconda I installed in my windows drive here:
c/Users/631/AppData/Local/Continuum/Anaconda21
Here's how I've tried to modify my .bashrc file:
export PATH=../../mnt/c/Users/631/AppData/Local/Continuum/Anaconda2/:../../mnt/c/Users/631/AppData/Local/Continuum/Anaconda2/Scripts/:../../mnt/c/Users/631/AppData/Local/Continuum/Anaconda2/Library/bin:$PATH
But so far bash has ignored my python interpreter in Anaconda.

Anaconda Environment in prompt/PS1 in MacOS?

When I was in Ubuntu installing Anaconda and activating a virtual environment modified my prompt to look like that:
(current-env)user#machine:dir
or as you define in .bashrc.
Now that I installed Anaconda in MacOS my prompt remain the same. I tried to configure that from Anaconda doing:
conda config --set changeps1 no
but nothing changed.
How can I modify my .bash_profile to have the current environment in PS1?
I managed to have that changing my shell from bash to zsh.
You can install zsh from here.
In recent versions, Conda has provided automated configuration for a number of shells via the conda init command. This command will edit relevant .*rc files to enable such features of PS1 change. Please see conda init --help for details.

Resources