Python environment construction memo on Mac

Use virtualenv to switch between multiple environments.

Install Homebrew

The procedure is on the Official Site,

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

You can install it with. Also, if xcode is not included, enter Command Line Tools.

$ brew doctor

If you get a warning, respond Your system is ready to brew. I will try to come out.

Install Python 2.7

$ brew install python

Will install python2.7. easy_install and pip are also installed at the same time.

Setuptools and Pip have been installed. To update them
  pip install --upgrade setuptools
  pip install --upgrade pip

To symlink "Idle" and the "Python Launcher" to ~/Applications
  `brew linkapps`

Is displayed, follow the instructions to execute the command.

Building a virtualenv environment

Install virtualenv and virtualenvwrapper with pip.

$ pip install virtualenv virtualenvwrapper

Since we need to load virtualenvwrapper.sh Set it to .bashrc etc.

export VIRTUALENVWRAPPER_PYTHON=/usr/local/Cellar/python/2.7.5/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENV_USE_DISTRIBUTE=true
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
    export WORKON_HOME=$HOME/.virtualenvs
    source /usr/local/bin/virtualenvwrapper.sh
fi

Multiple python installations

Normally, you can only install the latest version of python2 series and the latest version of python3 series. Make it possible to install other versions with the following command.

$ brew tap homebrew/versions

When you can, install the version you want to use.

$ brew install python25 python26 python3

This will install python 2.5, 2,6, 3.3.

Switch environment with virtualenv

$ mkvirtualenv --python='/usr/local/Cellar/python26/2.6.8/bin/python' py26

Then you will have a Python 2.6 virtual environment named py26.

To use this environment

$ workon py26

will do.

To return to the normal environment

$ deactivate

is.

Recommended Posts

Python environment construction memo on Mac
Python environment construction memo on Windows 10
Environment construction of python3.8 on mac
Mac environment construction Python
Python environment construction For Mac
[MEMO] [Development environment construction] Python
Building a Python environment on Mac
Anaconda python environment construction on Windows 10
Python environment construction
Anaconda environment construction on Mac (2018 version)
Create a Python environment on Mac (2017/4)
I checked Mac Python environment construction
Environment construction (python)
Python development environment construction on macOS
python on mac
python environment construction
Python --Environment construction
Python environment construction
Python3 TensorFlow for Mac environment construction
Emacs Python development environment construction memo
python environment construction
OpenCV3 & Python3 environment construction on Ubuntu
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)
Memo of python + numpy/scipy/pandas/matplotlib/jupyterlab environment construction on M1 macOS (as of 2020/12/24)
Python environment construction procedure memo using Docker on Windows10 Home
VScode environment construction (on Mac) & graph display in Python (@browser)
Create a python environment on your Mac
Build Python environment with Anaconda on Mac
Mac OS X development environment construction memo
My python environment memo
python windows environment construction
ConoHa environment construction memo
Install Python on Mac
Python development environment construction
Install Python 3 on Mac
python2.7 development environment construction
BigGorilla environment construction memo
Anaconda environment construction memo
Install Python 3.4 on Mac
Pyxel environment construction (Mac)
Python environment construction @ Win7
Python3 TensorFlow environment construction (Mac and pyenv virtualenv)
[Note] Python environment construction on rental server "CORESERVER"
Python explosive environment construction starting from zero (Mac)
Build a Python environment on Mac (Mountain Lion)
Build a Python development environment on your Mac
Python + Anaconda + Pycharm environment construction
Pyramid + mongodb environment on Mac
Anaconda environment construction on CentOS7
Django development environment construction memo
Install pygame on python3.4 on mac
Python environment construction (Windows10 + Emacs)
CI environment construction ~ Python edition ~
[Memo] Construction of cygwin environment
Anaconda3 python environment construction procedure
Build Python environment on Windows
Handling of python on mac
Anaconda3 × Pycharm environment construction memo
Update python on Mac to 3.7-> 3.8
Install pandas 0.14 on python3.4 [on Mac]
Python3 environment construction (for beginners)