A story that pyenv is stuck because the python execution command PATH does not pass

Overview

I wanted to put the execution PATH in Python of pyenv, but the known method didn't work at all, that is, I got stuck and melted it for a day. This happened when I did the following:

  1. Use Time Machine to migrate the environment from the existing Macbook Pro to Mac mini
  2. In the previous environment, pyenv was used, so please use which python to change to /Users/USERNAME/.pyenv/shims/python.
  3. For some reason, python's PATH was / usr / bin / python, which was the default for Mac. .. ..

So, the story of re-pathging python's PATH to /Users/USERNAME/.pyenv/shims/python. It's inconvenient because the version of python doesn't change.

Known procedure

Since I used zsh, the following settings are of course in .zshrc. (Reference: https://github.com/pyenv/pyenv)

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

Theoretically, if you do source .zshrc, your PATH should definitely go through. .. .. When I check it. .. ..

$ which python
/usr/bin/python

Huh ?? FUCK !!! I didn't go there! !!

Hmm, that's it. Isn't the order of PATH wrong?

$ vim /etc/paths

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Properly, the order of / usr / local / bin does not come first. .. .. .. By the way, if / usr / bin comes first, that executable file will be in the PATH preferentially.

If this happens, uninstall pyenv due to brain death and reinstall it. Even if you just do brew uninstall pyenv, there are configuration files here and there, so I crushed everything by referring to the following article. https://qiita.com/yasudadesu/items/1177aa93229e7c4b7a45

So, even if I soruce .zshrc the .zshrc again, it still doesn't heal. .. .. Yes, I gave up.

There was a god article

A great thank you to the article for someone who caused a similar event. https://dev.classmethod.jp/articles/pyenv-command-not-found/

The point is that you should try reassociating the links.

$ brew unlink pyenv
$ brew link pyenv
$ source .zshrc

Please come. .. .. Check Python's PATH with prayer.

$ which python
/Users/USER NAME/.pyenv/shims/python

I did it! !! !!

Finally

The ancestor is great

Recommended Posts

A story that pyenv is stuck because the python execution command PATH does not pass
What to do if the user name is changed and the pyenv library path does not pass
Python does not output errors or output just because the indent is misaligned
A story that sometimes does not work if pip is up to date
Examples and solutions that the Python version specified in pyenv does not run
A story that got stuck when trying to upgrade the Python version on GCE
There is a pattern that the program did not stop when using Python threading
The story that `while queue` did not work in python
Python list is not a list
How to pass the execution result of a shell command in a list in Python (non-blocking version)
The story that the version of python 3.7.7 was not adapted to Heroku
A story that struggled to handle the Python package of PocketSphinx
A special Python codec that seems to know but does not know
The story that 2D list replacement did not work in python
The story of making a module that skips mail with python
Note that the Google Maps Android API GoogleMap.getProjection is not a singleton
[python] [meta] Is the type of python a type?
Python> Python does not include the last offset
The story of blackjack A processing (python)
[Python] A program that rounds the score
About the problem that the python version of Google App Engine does not mesh
Deep Learning! The story of the data itself that is read when it does not follow after handwritten number recognition
[Python3] A story stuck with time zone conversion
A story stuck with handling Python binary data
After installing php7.2, the php command does not work
It's a Mac. What is the Linux command Linux?
It is said that libmysqlclient.so.18 does not exist
python Boolean operation does not return a Boolean value
A story that was convenient when I tried using the python ip address module
Solved the problem that MacVim installed by Homebrew was not built by python of pyenv
A command to check when something goes wrong when the server is not doing anything
What to do if Python does not switch from the System version in pyenv
When writing to a csv file with python, a story that I made a mistake and did not meet the delivery date