Reputation: 31
I learned programming in the MS-DOS environment with Assembly language and C, so please be a little gentle… I want to use Python (3.12.1 is installed) on MacOS 14.2.1 (Sonoma) where Python 3.9.6 is built in and untouched and Zsh is the shell of choice. The hardware is an Intel based MacBook Pro. I installed Homebrew and pyenv (mostly because I resist typing 3 after python every time I use it and I have previously had other versions of python installed and there will be more versions in the future). I had to use various internet articles to get this far… The problem is I am getting these results:
<name>@MacBook-Pro ~ % python
zsh: command not found: python
<name>@MacBook-Pro ~ %
<name>@MacBook-Pro ~ % python3
Python 3.12.1 (v3.12.1:2305ca5144, Dec 7 2023, 17:23:39) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
<name>@MacBook-Pro ~ %
— - -
@MacBook-Pro ~ % which python python not found
@MacBook-Pro ~ %
<name>@MacBook-Pro ~ % pyenv versions
* system (set by /Users/<name>/.pyenv/version)
<name>@MacBook-Pro ~ %
<name>@MacBook-Pro ~ % pyenv local 3.12.1
pyenv: version `3.12.1' not installed
<name>@MacBook-Pro ~ %
<name>@MacBook-Pro ~ % python -V
zsh: command not found: python
<name>@MacBook-Pro ~ %
My path looks like this:
<name>@MacBook-Pro ~ % echo $path
/Users/<name>/.pyenv/shims /Library/Frameworks/Python.framework/Versions/3.12/bin /usr/local/bin /usr/local/sbin /usr/local/bin /System/Cryptexes/App/usr/bin /usr/bin /bin /usr/sbin /sbin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin /var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
<name>@MacBook-Pro ~ %
So it appears to me that pyenv isn’t working as expected (by me, at least) Will someone please help?
Re-read the articles, searched internet for related issues. Installations seemed to be successful, so I haven't reinstalled anything. Some instructions /articles used shells other than zsh, so that could be part of the problem or I missed or misinterpreted a step.
Upvotes: 3
Views: 2290
Reputation: 1205
I had a similar issue while setting up my system
Here you can find for zsh you need to add it to path. Also there are additional associated feature would encourage you to go through the documentation above.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
The steps are quite clear but one thing it comes down is what processor you are running it on m-series chips or the intel chips.
On additional note you need gcc installed and if installed check for its compatablity
Also I found a medium article very helpful when I was setting it up for the very first time, Python: Creating a clean learning environment with pyenv, pyenv-virtualenv & pipX
Upvotes: 2