Catalina: pyenv stuck on migration to zsh

problem

Updating the OS to Catalina recommends migrating from bash to zsh. Here, if you move to zsh, pyenv will not work as it is.

environment

Try to reproduce

If you display the version with pyenv, it will certainly come out.

% pyenv versions
  system
  3.6.5
  3.6.5/envs/3.6.5_tensorflow_cpu
  3.6.5_tensorflow_cpu
* 3.7.4

The currently set python environment should be 3.7.4.

% pyenv local
3.7.4

However, when I run it, the system python comes up.

% python

WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Python 2.7.16 (default, Nov  9 2019, 05:55:08)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s on darwin
Type "help", "copyright", "credits" or "license" for more information.exit

solution

When using with sh, it is necessary to write the setting in .zshenv or .zshrc.

Add the following line to restore pyenv.

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Start .zshrc in an editor and

vim ~/.zshrc

I'll add the previous line. And if you source and reload it, it's okay

source ~/.zshrc

Try to start Python

% python
Python 3.7.4 (default, Sep 28 2019, 14:11:05)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

The python environment has come up as expected! !!

Recommended Posts

Catalina: pyenv stuck on migration to zsh
Catalina on Mac and pyenv
Install python2.x on catalina with pyenv
I want to do pyenv + pipenv on Windows
I get an error when I try to raise Python to 3 series using pyenv on Catalina
What to do if pyenv is not enabled (zsh)
Install pyenv on mac
How to use Pyenv
Installing pyenv on ubuntu 16.04
Install pyenv on OSX
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
Install pyenv on MacBook Air and switch python to use