I used ** pyenv ** ** pyenv **, a convenient tool for switching Python versions, and ** pyenv local ** without knowing the meaning, but suddenly [ When I looked at the pyenv page (https://github.com/yyuu/pyenv#how-it-works), I noticed that it carefully explained how it works. This is an abstract translation. Since it is an MIT license, I don't think you need a license, but please point out anything.
** pyenv ** intercepts ** python ** commands in shim executables (** shim executables **), decides which Python version to run on, and has the correct Python installation for your application. Pass. The shim executable uses the ** PATH ** environment variable mechanism.
When you run a command like ** python ** or ** pip **, the OS will take a series of directories with that name. Find the executable file. The list of directories is defined in the PATH environment variable with: (colon) A list of directories separated by.
--Find the ** pip ** executable file in the PATH environment variable --Find ** pip ** in the ** ~ / .pyenv / shims ** directory at the beginning of your PATH --Execute this ** pip ** and pass the command to ** pyenv **
When running the sim, pyenv checks which Python version to use in the following order.
The PYENV_VERSION environment variable (if defined). During the current shell session You can set this environment variable by using the ** pyenv shell ** command.
A. ** python **-version file in the current directory (if it exists). You can change this with the ** pyenv local ** command.
The. ** python **-version file in the parent directory. Go back to the route one by one. l
Global ** ~ / .pyenv / version ** files. It can be changed with the ** pyenv global ** command.
If none of the above is available ** "system" ** Python runs
Note: You can enable multiple versions at once, such as pyenv global 3.4.1 2.8.8. This is used when using ** python ** 2 and 3 in parallel, such as [tox](https://pypi. ** python **. Org / pypi / tox).
When pyenv determines the version, it passes the command to the correct ** Python ** version. Each ** Python ** version is installed under ** ~ / .pyenv / versions **. For example, it looks like this.
As for pyenv, rbenv works in almost the same way. Next, I would like to examine pyenv and vritualenv, rbenv and bundler.
Recommended Posts