How To Set up Python Development Environment – Ubuntu 14.04


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

Done

Advertisement
About

“I am not what I ought to be, I am not what I want to be, I am not what I hope to be in another world; but still I am not what I once used to be, and by the grace of God I am what I am”

Posted in Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Member of The Internet Defense League

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 516 other subscribers
Follow NextDime Networks on WordPress.com
My Community
Follow me on Twitter
Top Rated Posts
My Gravatar
nextdime

nextdime

“I am not what I ought to be, I am not what I want to be, I am not what I hope to be in another world; but still I am not what I once used to be, and by the grace of God I am what I am”

Verified Services

View Full Profile →

%d bloggers like this: