Macbook pro M1 command not found after oh my zsh - macos

I have anaconda installed in my computer and after installing Oh my zsh. Conda and python etc. command is not found.
zsh: command not found: conda
How can I fix this? It seems that the solutions I can find on the internet is a bit outdated.

It depends on how you installed it. You'll need to check your PATH variable, and compare against what you had in the original .zshrc file. You can then add it back like so
PATH="<PATH_TO_DIR_CONTAINING_CONDA:$PATH"

Related

no packages are recognised by zsh

I have previously installed npm, homebrew, oh-my-zsh and other runtime environments and worked perfectly on my Mac M1, until recently, no packages or runtime environments are being recognised.
When I enter brew I get error as zsh: command not found: brew but I can see in my opt/ path that there's homebrew folder and its content present,
Similarly for npm it shows error zsh: command not found: npm
I might have done something with my PATH
Here's a screenshot
Edit: My .bash_profile is empty, should it be empty??
On the M1 Macs, homebrew files are installed by default in /opt/homebrew, and the executables are usually placed in or linked to /opt/homebrew/bin. That directory is not in your search PATH - instead, it looks like you have the PATH settings for an Intel Mac.
As you noted, updating the PATH should fix the issue, but first you need to determine which shell you are using (the question is tagged both zsh and bash). It's probably zsh, since that's the default on newer versions of macOS, and it would explain why the .bash_profile is empty. You can double-check this with the command echo $0.
There are several ways to update the path, and many are described in other posts here at SO, such as this one. This will also work for zsh:
print 'PATH=$PATH:/opt/homebrew/bin' >> ~/.zshrc

How to install anaconda through home-brew m1 mac

I just got an m1 Mac and installed anaconda using home-brew:
brew install anaconda
It looked like it worked great, except that when I actually go to use anaconda and type "conda" I get the dreaded "conda command not found" error. How do I fix this?
Based on the answer given by #Peter here as well as the anaconda documentation, adding to path is no longer recommended. The answers here also did not solve the problem.
Figured it out! Challenge lay in the home-brew path. To run the conda init zsh command, detailed by #Sebastian in the answer here, I had to specify home-brew, as well as back up a couple directories. The command that actually got it done in terminal was:
~/../../opt/homebrew/anaconda3/bin/conda init zsh
Happy home-brew anaconda-ing on your new m1s everyone.

Mas OS Big Sur update - Python3 / conda / pip not found

Sorry if this is a stupid question. I use python/jupyter a lot and it's stopped working after updating from Mac OS High Sierra to Big Sur. I'm trying to figure out why, but I'm not great with command line stuff.
The problem. When I try python3, pip -v, conda, etc. it says "command not found". python still seems to run, but it's 2.7 and I know I had 3 (I probably had a few versions from untidy file systems). I want to avoid reinstalling all my packages and things again, because I know it's still there and I've done this a few times already.
Some clues. I know this OS upgrade moves me from bash to zsh. I've tried just switching back to bash with chsh -s /bin/zsh but it still says command not found. I also noticed the OS update creates a Mac HD (below System/Volumes) within my Mac HD, and in that second one seems to be still all my python3/conda/pip/etc. folders. Not sure if/how this matters. Or if this is just a path issue.
I just want to get Jupyter running again on my Mac without reinstalling all my myriad packages from square one. Any help appreciated!
After extreme toil and research, I finally found something that worked for me.
Find the location of your Anaconda3. For me it was in ~/opt/anaconda3
Open terminal and type source <location of anaconda3>/bin/activate and then in the next line, write conda init zsh
Close your terminal and open it again. You should see a prefix (base) when you open it again.
All in all, for me it was
rko3 ~ % source opt/anaconda3/bin/activate
rko3 ~ % conda init zsh
Let me know if this works for you!
PS. You may be tempted to change $PATH variables. Anaconda advises against that. Use this reference instead that suggests the above. https://docs.anaconda.com/anaconda/install/mac-os/
I've just resolved this exact issue on my machine after upgrading to Big Sur from Mojave.
The issue: MacOS, as of Catalina, no longer lets you use the system root folder. Anaconda used to install in this folder. After upgrading from Mojave to Big Sur, you'll likely find your anaconda3 folder, including all your environments and packages, located here: /System/Volumes/Data/anaconda3.
Here is what to do to fix it:
Open Terminal
Move the anaconda3 folder:
sudo mv /System/Volumes/Data/anaconda3 ~/
Download Anaconda's Conda Prefix Replacement (crp) tool:
curl -L https://repo.anaconda.com/pkgs/misc/cpr-exec/cpr-0.1.1-osx-64.exe -o cpr && chmod +x cpr
Run the CRP tool (this will take a few minutes):
./cpr rehome ~/anaconda3/
Source anacoda3
source ~/anaconda3/bin/activate
Initiate conda
conda init
Quit Terminal and open it again.
Edit: Someone didn't like that I ended this answer with "That's it! Enjoy". In the scenario described, the steps above were indeed all it took to resolve the issue. If you're experiencing the same issue, I hope this helps resolve it, so you can get back to enjoying your updated OS.
Seems like your environement is not activated. Zsh sources ~/.zshrc while bash sources ~/.bashrc.
You can copy lines related to conda from your ~/.bashrc to your ~/.zshrc.
AF
Open the Anaconda navigator and click on the Environments section. There you will see the base (root) and a green triangle next to it.
Click on the triangle and select Open Terminal.
Now, in the terminal you will be already in the necessary directory for anaconda and you can then update any packages.
For example, just by writing conda update --all you can update all packages available for updates.

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

I accidentally delete zsh from /bin folder in Mac

I delete the zsh binary from bin folder , so when i try to change my shell i get this :
chsh: WARNING: shell '/bin/zsh' does not exist
I don't know how to reinstall zsh shell and MacOs come with zsh by default.
The easiest thing would be to install zsh using brew (which will install it in /usr/local/bin/zsh) and then symlink it to /bin/zsh.
There are obvious more ways to fix this, but this seems (to me) to be the simplest.
I fixed that problem using mac tools. I invested only about 30 min of my time whith the reinstall option. It's obviously there is a way to generate a zsh binary, but I find easy reinstall the osx due to Osx come by default with the zsh binary and brew install doesn't install the zsh binary. On the other hand, there must a way to install zsh from scratch but I think find the correct way would take more time

Resources