Conda command not working on macOS - bash

I installed Anaconda on macOS. It installed successfully, but when I ran the command in terminal it does not recognize the command conda. On my initial search, I found out I have look if the environment variable is set in .bash_profile. As the following picture shows the path is all set, but I can not still run the command.

You are not using bash but zsh as your current shell.
zsh does not source .bash_profile - instead, it sources the .zprofile file for its initialization.
So, just copy the export PATH=... line to the .zprofile file (create it if it does not exist). Logout and login, and it should work.

Related

"flutter: command not found" in ubuntu

I'm having trouble with installing Flutter on ubuntu.
Attached is an image of my terminal with the steps I've followed, and the files associated with the flutter directory.
I've followed the steps shown on https://flutter.io/docs/get-started/install/linux and also tried to install with git clone.
https://i.stack.imgur.com/ltmNd.png
I think your problem is in the pwd part of the export command.
Replace the single quotes in 'pwd' with Backtick/back quote (``) like this
export PATH="$PATH:`pwd`/flutter/bin"
EDITED
Above command will just work until you close the terminal.
To make the change permanent you have to edit the .bashrc (or .zshrc, etc), using a text editor like vim, gedit or nano and place the same command at the end of the file.
vim ~/.bashrc or nano ~/.bashrc
Add the next line at the end of the file
# Add flutter to the path
export PATH="$PATH:`pwd`/flutter/bin"
Restart your terminal and verify that your PATH was set correctly with the echo $PATH command
Good luck!!
I am using Linux 18.04 version.
first, add the flutter path in .bash_profile as
export PATH="$PATH:(''flutter path)/flutter/bin"
I have this problem.run the following command in the terminal
source '(flutter path)'.bash_profile'

Terminal doesn't work (bash commands aren't recognizable)

I have macOS Sierra version 10.12.6
I tried to add a path using the terminal. I entered source ~/.bash_profile and then a text file opened and I entered my path.
But then the terminal stopped responding and bash commands are not recognizable anymore.
If I enter: source ~/.bash_profile nothing happens.
And if I enter any environment related command an error message shows: -bash: printenv: command not found
How can I fix this?
You've probably messed up your path. When you're setting a path it's important to append to it rather than overwrite, or you lose access to all the system paths; /usr/local/sbin, /usr/local/bin, /usr/sbin etc. When setting a new path make sure you use:
$PATH=$PATH:/path/to/add
You can fix this by removing the line from .bash_profile where you overwrote the path. Please paste the contents of .bash_profile if this does not work.
You've replaced $PATH with some of your values and you might not be able to update .bash_profile because of the unavailability of nano. Use the following command to access nano and environment variables.
export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
After using the command you can use nano ~/.bash_profile to fix the problem.

conda command not found even though path is exported

I installed anaconda3 into my home directory. This is what I am seeing within the terminal:
and my .bash_profile looks like this:
export PATH="/Users/spotter/anaconda3/bin:$PATH"
So I don't understand why conda is not being recognized. When I navigate to anaconda3/bin there is a file called conda in there, but even when I try to call it within that pathway it is still not found.
Spotter, your path to conda is incorrect.
I'm on High Sierra MAC OS and just installed Anaconda3 via HomeBrew command. I had issue with running :
conda
It'd also give me:
-bash: conda: command not found
I tried running:
export PATH=~/anaconda3/bin:$PATH
but it needs ENTIRE path. so here are the correct steps:
$ nano ~/.bash_profile
Now export the ENTIRE path, in my case it was:
export PATH=/usr/local/anaconda3/bin:$PATH
Exit out and run:
$ source ~/.bash_profile
Then try:
$ conda
it'll output:
$ conda --version
conda 4.4.10
I had to type source ~/anaconda3/bin/activate.
For anyone that landed here that is using a non-standard shell (zsh for example) the installer 5.3.1 currently changes the bash_profile not the current active default terminal.
Just open ~/.bash_profile, find the block that is added by the installer and copy it into your .zshrc file (if using zsh)
in Mac OS, for conda >4,4, the conventional way of exporting path (export PATH="Users/myuser/anaconda3/bin:$PATH") is NOT recommended anymore. First, see what is error message in your terminal in Mac when you type conda --version. If it says zsh conda not found then you are using ZSH terminal, so modifying any bash file is useless. In this case, you need to edit your .zprofile. on the other hand, if you get error like bash conda not found you edit .bash_profile. Lets, say we have zsh error, then type in terminal:
sudo nano ~./zprofile
located your conda.sh file by searching in your finder. Most probably it is in
~/anaconda3/etc/profile.d/conda.sh
(for me it was like: /Users/hasbah/opt/anaconda3/etc/profile.d/conda.sh, but instead of anaconda3, it might be conda)
then you type in .zhprfile this:
. /Users/myuser/opt/anaconda3/etc/profile.d/conda.sh
conda activate base
then you save (ctrl+X and Y when was asked to save) and restart the terminal.
Now if you type conda --version you will see it.
so, in short:
sudo nano ~/.zproflie
. /Users/myuser/opt/anaconda3/etc/profile.d/conda.sh
conda activate base
save ./zproflie file
close terminal
open new terminal
conda --version
Rather than adding the ~/anaconda3/bin to your PATH, you should add
. ~/anaconda3/etc/profile.d/conda.sh
conda activate base
to your .bash_profile or .bashrc, or type that in a shell, if you don't want it to be activated for each shell. This is the recommended way to activate conda since conda 4.4. See: https://github.com/conda/conda/blob/master/CHANGELOG.md#440-2017-12-20

Terminal doesn't start properly. bash command not found

I have problems with my terminal after trying to install Homebrew on my Mac. When I start the terminal I get :
-bash: touch: command not found
When I do echo $PATH I get:
/usr/local/bin:??
I've tried several suggestions like
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
and then it works, but when I restart my terminal, it starts all over.
According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.
Mac OS X runs a login shell by default for each new terminal window, calling .bash_profile instead of .bashrc.
Setup your PATH variable in .bash_profile
vim ~/.bash_profile
correct PATH variable with below single line(which is working fine as per the question)
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

I have to type export PATH=~/anaconda/bin:"$PATH" everytime I rerun the terminal

I have installed the Anaconda for Mac, but there is something wrong with me:
when I type the commandwhich conda or which ipython, I get conda not found and ipython not find
Then I find this command export PATH=~/anaconda/bin:"$PATH" works for me. It solves the problem above, but everytime I rerun the terminal the problem is still there, I have to type it again.
so I want to find a way to solve the problem fundamentally
I have tried to add it into the ~/.bashrc, ~/.profile, ~/.bash_profile, but these don't work for me.
Try this in .bash_profile
export PATH="$HOME/anaconda/bin:$PATH"
Then try launching a new terminal and running:
echo $PATH
The output should start with /anaconda/bin:
If that still doesn't work... A work around might be to invoke bash after running terminal i.e. type "bash". Which should cause bash to launch with .bash_profile
I run on MacOs Catalina 10.15 and this did the trick for me:
shell is zsh !
$ source /Users/myprofilename/anaconda3/bin/activate
then
$ conda init zsh
the new anaconda documentation also highlights this:
Make sure you're not using ZShell or another form of a shell. If the case you'd have to add the path to your respective shell file, e.g .zshrc.
sudo xed /etc/environment
after open this archive add :/home/youruser/anaconda3/bin
If you're using ZShell follow the steps below:
In your terminal type open ~/.zshrc
Add the following to the file export PATH=/opt/homebrew/bin:$PATH
Save your file and then run the following command source ~/.zshrc
Please note that the homebrew path on Apple silicon is /opt/homebrew/bin

Resources