I'm completely new to python, and I haven't touched it so much, so I'll start by building the environment!
Since python is preinstalled on Mac, check first.
$ python --version
Python 2.7.10
$ python3 --version
Python 3.7.7
There is, so preparation is OK!
However, if you do not have it or want to use the latest python, you need to install it separately. Let's install pyenv with homebrew and drop python
$ brew install pyenv
Complete after setting environment variables in bash_profile etc.
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
Check the version that can be installed and install the one you need
$ pyenv install --list
Check the available version and run pyenv global
to use the installed version
(Install 3.8.2 here)
$ pyenv install 3.8.2
$ pyenv versions
$ pyenv global 3.8.2
$ python3 --version
Now you're ready! You can already create something like sample.py and run it with python sample.py!
What a simple environment construction. ..
Recommended Posts