I have installed Python in MacBook But As I type python in my terminal It is giving zsh: command not found: python in Python. We are going to Learn about All Possible Solutions So Lets Get Start with This Article.
How zsh: command not found: python Error Occurs?
I have installed Python on MacBook But As I type python in my terminal It is giving the following error.
zsh: command not found: python
So here I am writing all possible solutions that I have tried to resolve this error.
How To Solve zsh: command not found: python Error?
- How To Solve zsh: command not found: python Error?
To Solve zsh: command not found: python Error First Of all, Just find Python Installation Path. Open the Terminal. In your text editor, open the ~/.bash_profile file. For example: atom ~/.bash_profile; To this file, add the following line at the bottom: export PYTHONPATH=”/Users/my_user/code” Save this text editor file. Close the terminal. Restart the terminal. You can now read the new settings. Type: echo $PYTHONPATH Hope Now, Your error must be solved.
- zsh: command not found: python
To Solve zsh: command not found: python Error First of all, Just Open Your terminal and Run This Command: echo “alias python=/usr/bin/python3” >> ~/.zshrc Please note that You Must add the Python version at the end of this line python=/usr/bin/python3 if you are using python 3 then you need to Use python3 now, your error should be fixed.
Solution 1: Set Python PATH
- First Of all, Just find Python Installation Path.
- Open the Terminal.
- In your text editor, open the ~/.bash_profile file. For example: atom ~/.bash_profile;
- To this file, add the following line at the bottom:
- export PYTHONPATH=”/Users/my_user/code”
- Save this text editor file.
- Close the terminal.
- Restart the terminal. You can now read the new settings.
- Type: echo $PYTHONPATH
- Hope Now, Your error must be solved.
Solution 2: Run this Command
First of all, Just Open Your terminal and Run This Command.
echo "alias python=/usr/bin/python3" >> ~/.zshrc
Please note that You Must add the Python version at the end of this line python=/usr/bin/python3 if you are using python 3 then you need to Use python3 now, your error should be fixed.
Solution 3: Export profile
First Of All Open Your terminal and Edit bash_profile with this command.
sudo nano ~/.bash_profile
It will ask You for Your Password Just Enter your password and paste the following lines
PYTHONPATH="<Your Python Path>"
export PYTHONPATH
Can’t find Python Path? It should be here (in most cases).
# For python
/usr/local/bin/python
# For python3
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
Then Press control + x
to exit, and press y
for saving. and Then Press `enter‘ to return to the terminal window Then You have To Source it using the following command in a terminal, run
source ~/.bash_profile
Now, Your error must be solved.
Summary
It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read