pyenv
Install with brew
$ brew install pyenv
Verification
$ pyenv --help
Usage: pyenv <command> [<args>]
Some useful pyenv commands are:
commands List all available pyenv commands
local Set or show the local application-specific Python version
global Set or show the global Python version
shell Set or show the shell-specific Python version
install Install a Python version using python-build
uninstall Uninstall a specific Python version
rehash Rehash pyenv shims (run this after installing executables)
version Show the current Python version and its origin
versions List all Python versions available to pyenv
which Display the full path to an executable
whence List all Python versions that contain the given executable
See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/yyuu/pyenv#readme
$ brew info pyenv
pyenv: stable 20160509, HEAD
Python version management
https://github.com/yyuu/pyenv
/usr/local/Cellar/pyenv/20160509 (489 files, 2.1M) *
Built from source on 2016-06-02 at 10:49:26
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pyenv.rb
==> Dependencies
Recommended: autoconf ✔, pkg-config ✔, openssl ✔, readline ✔
==> Options
--without-autoconf
Build without autoconf support
--without-openssl
Build without openssl support
--without-pkg-config
Build without pkg-config support
--without-readline
Build without readline support
--HEAD
Install HEAD version
==> Caveats
To use Homebrew's directories rather than ~/.pyenv add to your profile:
export PYENV_ROOT=/usr/local/var/pyenv
To enable shims and autocompletion add to your profile:
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
Pass through.
echo 'export PYENV_ROOT=/usr/local/var/pyenv' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
python
Check the installable version
$ pyenv install --list
Installation
$ pyenv install 3.5.1
Downloading Python-3.5.1.tgz...
-> https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
Installing Python-3.5.1...
BUILD FAILED (OS X 10.11.5 using python-build 20151028)
Inspect or clean up the working tree at /var/folders/pq/m1yrrt652vg03wf5q66xk0m00000gn/T/python-build.20160529161005.9447
Results logged to /var/folders/pq/m1yrrt652vg03wf5q66xk0m00000gn/T/python-build.20160529161005.9447.log
Last 10 log lines:
File "/private/var/folders/pq/m1yrrt652vg03wf5q66xk0m00000gn/T/python-build.20160529161005.9447/Python-3.5.1/Lib/ensurepip/__main__.py", line 4, in <module>
ensurepip._main()
File "/private/var/folders/pq/m1yrrt652vg03wf5q66xk0m00000gn/T/python-build.20160529161005.9447/Python-3.5.1/Lib/ensurepip/__init__.py", line 209, in _main
default_pip=args.default_pip,
File "/private/var/folders/pq/m1yrrt652vg03wf5q66xk0m00000gn/T/python-build.20160529161005.9447/Python-3.5.1/Lib/ensurepip/__init__.py", line 116, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/private/var/folders/pq/m1yrrt652vg03wf5q66xk0m00000gn/T/python-build.20160529161005.9447/Python-3.5.1/Lib/ensurepip/__init__.py", line 40, in _run_pip
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
Oh. I got scolded. .. ..
It seems that you will get angry if the command line tool of xcode is not included, so install it.
$ xcode-select --install
The installation is confirmed by GUI, so what's good ...
Re-execute
$ pyenv install 3.5.1
Downloading Python-3.5.1.tgz...
-> https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
Installing Python-3.5.1...
Installed Python-3.5.1 to /Users/LowSE01/.pyenv/versions/3.5.1
This time it's OK.
Specify the version to use by default
$ pyenv global 3.5.1
Verification
$ python --version
Python 3.5.1
OK if Version is installed.
anaconda
Installation execution
$ pyenv install anaconda3-4.0.0
Specify the version to use by default
$ pyenv global anaconda3-4.0.0
IntelliJ + Python