[PYTHON] What to do if pyenv is not enabled (zsh)

Premise

Discovery that pyenv is not used

Confirm that it is specified in 3.8.6 in pyenv.

% pyenv versions
  system
* 3.8.6 (set by /Users/user/.pyenv/version)

However, when I actually checked the version of python, it was not 3.8.6! !!

% python3 -V
Python 3.9.0
% python -V
Python 2.7.16

If you check your PATH in the first place

% echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/user/.pyenv/bin

First comes / user / local / bin!

% which python
/usr/bin/python
% which python3
/usr/local/bin/python3

I see, pyenv is not used. ~ / .zshenv looks like this

% cat ~/.zshenv
export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

There seems to be no problem in terms of content. When it comes to rewriting the order of PATH, is it around / etc / zprofile?

% cat /etc/zprofile
# System-wide profile for interactive zsh(1) login shells.

# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
# and zshoptions(1) for more details.

if [ -x /usr/libexec/path_helper ]; then
	eval `/usr/libexec/path_helper -s`
fi

I doubt that it is necessary to rewrite such a place, so check the [official site] of pyenv (https://github.com/pyenv/pyenv#homebrew-on-macos). Then, to ~ / .zshrc

~/.zshrc


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

Immediately move the part described in ~ / .zshenv to ~ / .zshrc and restart the terminal!

Then

% echo $PATH
/Users/user/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/user/.pyenv/bin
% python -V
Python 3.8.6
% which python
/Users/ham/.pyenv/shims/python

Conclusion

--In the case of zsh, not all environment variables should be described in ~ / .zshenv, and ~ / .zshrc is also used. --Check the official documentation.

Recommended Posts

What to do if pyenv is not enabled (zsh)
What to do if pyenv install does not proceed with an error
What to do if the user name is changed and the pyenv library path does not pass
What to do if sys / cdefs.h does not exist
What to do if Japanese language support is not completely installed on Ubuntu 16.04
What to do if yum breaks
What to do when Japanese is not displayed on matplotlib
What to do if the progress bar is not displayed in tqdm of python
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do if Python does not switch from the System version in pyenv
What to do if python says "fatal error:'stdio.h' file not found"
What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
What to do if the inode is exhausted on EC2 Linux
What to do if there is a decimal in python json .dumps
What to do if the Pipenv environment is corrupted by updating Homebrew
What to do if you get Could not fetch URL 443 with pip
What to do if pipreqs results in UnicodeDecodeError
What to do if you can't pipenv shell
What to do if mod_fcgid cannot resolve UnicodeEncodeError
What to do if rails s doesn't work
What to do if pip cannot be installed
What to do if atom autocomplete-python doesn't work
What to do if Docker-sync suddenly stops working
What to do if "amazon-linux-extras" → "No module named amazon_linux_extras"
What to do in my case when pyenv install is not possible after upgrading to macOS Big Sur
What to do if you get angry with swapon failed: Operation not permitted
What to do if CERTIFICATE_VERIFY_FAILED occurs when nltk.download () is done on macOS pyhon
What to do if you get an error when installing python with pyenv
What to do if you get "Python not configured." Using PyDev in Eclipse
What to do if abort is displayed when inputting camera video in OpenCV
What to do if (base) is displayed at the beginning of the Mac terminal
What to do if pip install fails in Xcode 5.1
What to do if you can't pip install mysqlclient
curl: (60) What to do when Issuer certificate is invalid.
No module named What to do if you get'libs.resources'
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
What to do if SciPy installation fails on CentOS
What to do if a UnicodeDecodeError occurs in pip
pipenv shell is no longer available ... what to do?
What to do if pip install fails to install dependent libraries
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do if ubuntu says your password is too short to change [passwd command] [ubuntu]
What to do if you get an OpenSSL error when installing Python 2 with pyenv
What to do when is not in the sudoers file.This incident will be reported.
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium
What to do if the package dependency cannot be repaired
What to do if you are addicted to Windows character code
What to do if pip gives a DistributionError in Homebrew
What to do when PyCharm font is strange or garbled
What to do if you get "coverage unknown" in Coveralls
What to do if you can't sort files with subscripts
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
If it is not easy to understand, it cannot be improved.
What to do if package installation fails when deploying to heroku
What to do if `pip install matplotlib` fails on Mac
What to do if you can't log in as root
What to do if you can't use WiFi on Linux
What to do if Linux VLC can no longer rotate
What to do if pip install mysqlclient fails on MacOS
Why django-import-export import is so slow and what to do