Check version
Python is already installed in Ubuntu. and check what version installed in it.
$ python -V
Install needed package for python development
$ sudo apt-get install build-essential python-dev libsqlite3-dev libreadline6-dev libgdbm-dev zlib1g-dev libbz2-dev sqlite3 zip
Install python3
$ sudo apt-get install python3 python3-dev
Enable easy_install
To use easy_install you need to install setuptools. setuptools is not maintained so then instead of it, distribute take the place of it. but now setup tool is updated. if you want to know more check official site
$ mkdir ~/src
Download setup file.
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
Execute it and start install
$ sudo python ez_setup.py
Install pip
After enabling easy_install, install pip next. What is pip? check document
$ sudo easy_install pip
Install virtualenv and virtualenvwrapper
Virtualenv enables you to make different environment with version python or combination of package. virtualenv
$ sudo pip install virtualenv virtualenvwrapper
Setting for virtualenvrapper
$ vim ~/.bashrc
~/.bashrc
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
fi
$ source ~/.bashrc
Now you can make virtual python environment easily.
mkvirtualenv : make virtualenv
$ mkvirtualenv work
In virtualenv, its name is at the head of prompt and you can use pip freely in it.
(work)webees@ubuntu:~$ pip install Django
Freeze : confirm what packages are installed
(work)webees@ubuntu:~$ pip freeze
Django==1.6
argparse==1.2.1
wsgiref==0.1.2
Deactivate : get away from virtualenv
(work)webees@ubuntu:~$ deactivate
virtualenv with python3
Confirm the path to python3
$ which python3
/usr/bin/python3
Set path with -p option
$ mkvirtualenv -p /usr/bin/python3 python3
(python3)webees@ubuntu:~$ python -V
Python 3.2.3
Workon : switch virtualenv or confirm its exist.
$ workon
python3
work
Rmvirtualenv : remove virtualenv
$ rmvirtualenv work
Leave a Reply