Starting with macOS Catalina, Apple changed the main system used in the Terminal from bash to zsh.
Let us fix Zsh command not found error in the following manner through the terminal and other methods.
Check the Syntax
It is common to get a command not found error because of misspellings or typos.
You get it when typing things manually, and unintended characters get typed.
You should double-check the command to see any errors.
We would recommend copying the command directly into the terminal instead of
2.
Set $Path environment in .zshrc file
A path in a file system points to a specific location.
PressCommand+Spacebarto initiate the Spotlight search
2.
Search and head to theterminal.
Paste the following command and pressenter.
This will fix the zsh command not found error on macOS.
Here is how you look to see if the package is installed.
Enter the following command and pressenterto list all the installed packages.
For Python Packages
1.
If you want to see installed Python packages, then enter the following command and pressenter.
Here is how you create a Zsh profile before entering other commands.
Enter the following command in the terminal and pressenterfor redirecting to the home directory.
After that, enter the following command to create a Zsh profile.
Now, let us check Zsh profile by opening it.
You will see zshrc file open in the text editor, confirming the creation of the Zsh profile.
Reinstalling macOS can be a solution for fixing the Zsh command not found error.
For this as well, you’re able to use the official guide onrestoring macOS through Time Machine.
How Do I Switch to Zsh Commands on Mac?
For macOS Catalina and later versions, Zsh should already be set as your default shell.
If it returns something like /bin/zsh, then Zsh is already your default shell.
Change to Zsh (if needed):Enter the commandchsh -s /bin/zshin the Terminal.
You might need to key in your password to confirm this change.
Restart Terminal:Finally, close and reopen your Terminal.
This starts a new session using Zsh.
Using package managers like HomeBrew or Macport, along with Zsh, can make things easier.
confirm to key in the correct commands to deal with the errors.
source: www.techworm.net