Installation procedure + usage of "virtualenv" and "pythonz" in Mountain Lion environment

1.First of all

Python is installed by default in Mountain Lion. However, if you want to use the latest Python environment but want to keep the Python that is installed as standard on your Mac, you will not be able to install the latest Python. This time, I would like to write about "virtualenv" and "pythonz" that can leave the Python that is installed as standard on the Mac as it is and can use various Python environments.

2. Prerequisites

-Easy_install must be installed

*) If easy_install is not installed, run the following command.

$ curl -O https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py
$ sudo python distribute_setup.py

3. Installation procedure

(1) Install virtualenv using easy_install.

$ sudo easy_install virtualenv

(2) Execute the following command to install pythonz.

$ curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash

(3) Add the following contents to .bashrc.

[[ -s $HOME/.pythonz/etc/bashrc ]] && source $HOME/.pythonz/etc/bashrc

(4) Reflect the modified contents of .bashrc.

$ source ~/.bashrc

4. pythonz command collection

(1) cleanup

$ pythonz cleanup

(2) install

$ pythonz install (version)

*) You can check the installable Python version using the following command.

$ pythonz list -a

(3) list

$ pythonz list	#Show the currently installed version of Python
$ pythonz list -p #Show the path of the currently installed Python
$ pythonz list -a #Installable with pythonz shows Python version

(4) uninstall

$ pythonz uninstall (version)

(5) update

$ pythonz update

5. Build a Python virtual environment with virtualenv

(1) Create a working folder for virtualenv. This time, create a .virtualenv folder on your home directory.

$ mkdir ~/.virtualenv
$ cd ~/.virtualenv

(2) Create a Python virtual environment with the virtualenv command.

#Basic commands
$ virtualenv -p (Installation path for Python executable files) (Virtual environment name) # 「-If you do not specify "p", the Python version is 2..It will be 5.
#Example of use
$ virtualenv -p ~/.pythonz/pythons/CPython-2.7.5/bin/python py27

(3) Start up the Python virtual environment with the following command.

$ source py27/bin/activate #"Py27" is the virtual environment name created above. Please read as appropriate.

(4) To terminate the Python virtual environment, execute the following command.

$ deactivate

Recommended Posts

Installation procedure + usage of "virtualenv" and "pythonz" in Mountain Lion environment
Installation and easy usage of pytest
Clean python environment with pythonz and virtualenv
Installation of Python3 and Flask [Environment construction summary]
python development environment -use of pyenv and virtualenv-
Anaconda3 environment installation procedure
Scrapy environment installation procedure
[Python] Chapter 01-02 About Python (Execution and installation of development environment)
Mechanism of pyenv and virtualenv
Source installation and installation of Python
Correspondence record of minor troubles in Linux installation and settings, etc.
Using TensorFlow in the cloud integrated development environment Cloud9 ~ Basics of usage ~
Environment construction of python and opencv
Installation of SciPy and matplotlib (Python)
[Django] Memorandum of environment construction procedure
PySpark 1.5.2 + Elasticsearch 2.1.0 Installation procedure and execution