Python Forum

Full Version: Can't Find Python (or Something)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been trying to use Python for several days without success. So I am seeking support.

I am running MacOS Sonoma 14.1.1 on a new MacBook. I installed 'successfully' Python 3.12.0. I had a long Python script that I have not been able to get running as every attempt, no matter what I do, results in file not found errors.

So I wrote a simple Python script titled hello_world.py in hopes I could locate and repair the situation.

Here is my code:

`
# Print the message "Hello, World!"
print("Hello, World!")
`

No matter what I do I get this result:

`
zsh: command not found: python
`

I have verified with the command python3 --version that Python exists as it returns 'Python 3.12.0'

I have verified that the PATH included usr/bin and usr/local/bin

I have tried adding a .zshrc file with paths to these directories.

I have even tried explicitly running the commands /usr/local/bin/python hello_world.py and /usr/bin/python hello_world.py

Every attempt simply returns the same or similar error indicating command not found or sometimes no such file or directory.

Three days in, I would cherish hearing from anyone who may know what I am doing incorrectly.

thanx,

ken
Too little information (for example how have you tried to run the code) but this should be self explanatory:

Quote:zsh: command not found: python
I have verified with the command python3 --version that Python exists as it returns 'Python 3.12.0'

It appears that you have python3 but you get error for trying to run python.
(Nov-26-2023, 02:23 AM)pklind Wrote: [ -> ]I have verified with the command python3 --version that Python exists as it returns 'Python 3.12.0'
Then all is ok.
Python is not pre-installed on Mac automatically anymore.
Previously Mac came with a pre-installed Python 2.7 and then python command did return 2,7(now dead💀).
(Nov-26-2023, 02:23 AM)pklind Wrote: [ -> ]I have tried adding a .zshrc file with paths to these directories.
You can use alias in .zshrc file.
Do first which python3 the result Path:
alias python=/<your path>/python3
Then both python and python3 point to Python 3.12.

Some other way in this link like eg using pyenv .