virtualenv is a tool to create isolated virtual environments or sandboxes. One project written 2.7 does not affect the other project written in 3.4. Both can reside on the same machine without creating conflict.
Installation commands in Ubuntu:
#Get the installation file
sandesh@sandesh:~$wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.7.tar.gz
#the virtualenv zipped file will be downloaded
sandesh@sandesh:~$tar -xvzf virtualenv-12.0.7.tar.gz
sandesh@sandesh:~$cd virtualenv-12.0.7
#install virtualenv
sandesh@sandesh:~/virtualenv-12.0.7$python virtualenv.py myenv
#a new folder called myenv will be created
Use virtualenv in Ubuntu:
# this runs the activate file inside the bin folder
sandesh@sandesh:~/virtualenv-12.0.7$source myenv/bin/activate
#myenv is the name of the virtual environment I created above.
#To install any package inside this virutal environment we execute the following command.
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$pip install django
Collecting django
Using cached Django-1.7.4-py2.py3-none-any.whl
Installing collected packages: django
Successfully installed django-1.7.4
#we can check what packages are installed inside the virtualenv using following command.
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$ pip freeze
Django==1.7.4
#to get out of the virtualenv
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$ deactivate
sandesh@sandesh-S400CA:~/virtualenv-12.0.7$
Installation commands in Ubuntu:
#Get the installation file
sandesh@sandesh:~$wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.7.tar.gz
#the virtualenv zipped file will be downloaded
sandesh@sandesh:~$tar -xvzf virtualenv-12.0.7.tar.gz
sandesh@sandesh:~$cd virtualenv-12.0.7
#install virtualenv
sandesh@sandesh:~/virtualenv-12.0.7$python virtualenv.py myenv
#a new folder called myenv will be created
Use virtualenv in Ubuntu:
# this runs the activate file inside the bin folder
sandesh@sandesh:~/virtualenv-12.0.7$source myenv/bin/activate
#myenv is the name of the virtual environment I created above.
#To install any package inside this virutal environment we execute the following command.
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$pip install django
Collecting django
Using cached Django-1.7.4-py2.py3-none-any.whl
Installing collected packages: django
Successfully installed django-1.7.4
#we can check what packages are installed inside the virtualenv using following command.
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$ pip freeze
Django==1.7.4
#to get out of the virtualenv
(myenv)sandesh@sandesh:~/virtualenv-12.0.7$ deactivate
sandesh@sandesh-S400CA:~/virtualenv-12.0.7$
No comments:
Post a Comment