It's the 15th day of the LIG Advent Calendar! Hello, this is Jack (@kazuhikoyamashita).
My recent hobby is doing matrix calculations in Python. This time, I would like to summarize the procedure for building a Python environment using pyenv.
Execute the following command to install pyenv. It can be easily installed with the brew command.
% brew install pyenv
Add the following settings to your .zprofile so that pyenv will run automatically when you start the terminal.
% echo 'if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi' >> ~/.zprofile
Use the source command to reflect the settings added to .zprofile. The command to reflect is as follows.
% source ~/.zprofile
Check the version of Python that comes standard with your Mac. To check the version, execute the following command. In my environment, I currently have Python 2.7.10.
% python --version Python 2.7.10
This time, I will use pyenv to install the latest (as of December 15, 2015) Python 3.5.0.
To install Python 3.5.0, execute the following command.
% pyenv install 3.5.0
If you want to install another version, you can check the installable version with the following command.
% pyenv install --list
To switch from the system Python environment to the Python environment installed by pyenv, execute the following command.
% pyenv global 3.5.0 % python --version Python 3.5.0
You are now switched to Python 3.5.0.
Follow the steps below to output "Hello, World!".
% python Python 3.5.0 (default, Dec 9 2015, 17:22:19) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> string = 'Hello, World!' >>> str(string) 'Hello, World!'
Next time, I would like to write an article on matrix calculation. that's all!