Search This Blog

Saturday, April 20, 2013

bpython supports virtualenv

With the help of virtualenv you can create different virtual environments for Python. Each environment can have installed different modules or have the same module but in different version.

Problem

Does bpython support virtualenv by default.

Solution

Yes, bpython supports virtualenv environments by default. Below is how you can verify it.
 
root@manage2:~# python
Python 2.7.3 (default, Aug  1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/pymodules/python2.7']
>>>

Virtualenv local configuration (see the (novaclinet) string representing the name of the environment at the beginning)
 
root@manage2:~/virtualenv.d/novaclient/bin# source  activate
(novaclient)root@manage2:~/virtualenv.d/novaclient/bin# python
Python 2.7.3 (default, Aug  1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/root/virtualenv.d/novaclient/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg', '/root/virtualenv.d/novaclient/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/root/virtualenv.d/novaclient/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg', '/root/virtualenv.d/novaclient/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/root/virtualenv.d/novaclient/lib/python2.7', '/root/virtualenv.d/novaclient/lib/python2.7/plat-linux2', '/root/virtualenv.d/novaclient/lib/python2.7/lib-tk', '/root/virtualenv.d/novaclient/lib/python2.7/lib-old', '/root/virtualenv.d/novaclient/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/root/virtualenv.d/novaclient/local/lib/python2.7/site-packages', '/root/virtualenv.d/novaclient/lib/python2.7/site-packages']

Global, system wide configuration
 
root@manage2:~# bpython
>>> import sys
>>> sys.path
['', '/usr/bin', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/pymodules/python2.7']
>>>

Virtualenv local configuration
 
(novaclient)root@manage2:~/virtualenv.d/novaclient/bin# bpython
>>> import sys
>>> sys.path
['', '/root/virtualenv.d/novaclient/bin', '/root/virtualenv.d/novaclient/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg', '/root/virtualenv.d/novaclient/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/root/virtualenv.d/novaclient/lib/python2.7', '/root/virtualenv.d/novaclient/lib/python2.7/plat-linux2', '/root/virtualenv.d/novaclient/lib/python2.7/lib-tk', '/root/virtualenv.d/novaclient/lib/python2.7/lib-old', '/root/virtualenv.d/novaclient/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/root/virtualenv.d/novaclient/local/lib/python2.7/site-packages']
>>>

No comments:

Post a Comment