0

I am trying to install the latest beta version of the new Python 3.8. My laptop is running macOS Mojave. I am following the tutorial on RealPython: https://realpython.com/intro-to-pyenv/

and have skimmed through similar questions, e.g. pyenv 3.6.5 BUILD FAILED macOS Mojave 10.14.5

First I run the commands:

brew install openssl readline sqlite3 xz zlib
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
curl https://pyenv.run | bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
$ exec "$SHELL"
pyenv install --list | grep " 3\.[8]"

Which run successfully and shows that Python 3.8.0b4 is the latest release, which I wish to install;

When attempting to install with:

pyenv install 3.8.0b4

The result reads:

-bash: pyenv: command not found

pyenv is installed however. Any idea about why the command isn't found?

(See the BASH terminal below).

enter image description here

Gustav Rasmussen
  • 3,720
  • 4
  • 23
  • 53

2 Answers2

1

Following PyEnv BUILD FAILED installing Python on MacOS

The below command successfully installed Python 3.8.0b4:

SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk MACOSX_DEPLOYMENT_TARGET=10.14 pyenv install 3.8.0b4

See output below:

enter image description here

Gustav Rasmussen
  • 3,720
  • 4
  • 23
  • 53
1

What you wrote in the description was different with what you typed in the shell.

According to the screenshot, pyenv was not initialized yet before python installation, which means command pyenv was not added into PATH and the sub-commands were not available either.

You'd better write the init scripts into your bash configuration file, like ~/.bashrc

export PATH="$HOME/.pyenv/bin:$PATH"

if command -v pyenv &>/dev/null; then
  eval "$(pyenv init -)"
fi
if command -v pyenv-virtualenv &>/dev/null; then
  eval "$(pyenv virtualenv-init -)"
fi

After that, start a new shell and do the Python installation.

You can check the README.md at the project's repo on GitHub for more info.

Simba
  • 23,537
  • 7
  • 64
  • 76