The aim is to build a python development environment
In the environment raised from Mojave to Catalina, when I did it normally, it did not work as expected with python3
or pip3
due to the difference in version, so I will try using around pyenv
to see if it works well.
homebrew
Start from here.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
$ brew install pyenv
$ pyenv -v
pyenv 1.2.17
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
https://github.com/pyenv/pyenv
By the way, in the case of zsh, it seems that the same settings should be made for .zshrc
.
Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile. https://github.com/pyenv/pyenv
I don't know why it's .zshrc
instead of .zprofile
.
Reflect
$ source ~/.bash_profile
Check the installable version
$ pyenv install -l
Install the version you want to use
$ pyenv install 3.7.7
Confirmation of installation
$ pyenv versions
* system (set by /Users/ykinomt/.pyenv/version)
3.7.7
Status quo confirmation
$ python -V
Python 2.7.16
switching
$ pyenv global 3.7.7
$ python -V
Python 3.7.7
Use local to switch by directory.
$ python -V
Python 2.7.16
$ pyenv local 3.7.7
$ python -V
Python 3.7.7
If you use local, a file called .python-version
will be created in that directory, and it will run with the specified version in that directory.
If you want to create an application, it may be better to specify it as local.
It's not necessary, but the version that comes out in the interpreter settings seems to be the one that was installed by the time VSCode started, so if you newly install with the above settings, you may not be able to select it unless you restart vscode once.
Recommended Posts