Notice how the /Users/Soma/.pyenv/shims directory is at the start of the PATH now. Restart your terminal, run echo $PATH again, and you'll now see output like this: /Users/Soma/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin if command -v pyenv 1>/dev/null 2>&1 then You can add this code to your ~/.bash_profile file to change your PATH. Your machine is finding the python executable in the /usr/bin directory. If you type echo $PATH, you'll have something like this: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin When you run python -version, your Terminal will perform the same steps it performs when any shell command is executed: it goes through each directory in your PATH and looks for the first executable named python. Most users are surprised that pyenv global 3.5.0 only changes a single line in a text file! When you run pyenv global 3.5.0, the /Users/Soma/.pyenv/version file is updated to contain "3.5.0". The pyenv versions command is just checking through the hierarchy and selecting the right Python version to use when a "shim interceptable" command like python or pip is run. It's basically the same as cat /Users/Soma/.pyenv/version. The pyenv global command simply reads the data in your /Users/Soma/.pyenv/version directory. This is a great opportunity to learn about how pyenv works under the hood.
0 Comments
Leave a Reply. |