I am very much new to the process of development of a web-application with django, and i came across this setting up and using virtual environment for python. So i landed with some basic questions.
What does this virtual environment exactly mean.
Does that has any sort of importance in the development of web-application using django and python modules.
do i have to worry about setting up of virtual environment each time in the development process.
A virtual environment is a way for you to have multiple versions of python on your machine without them clashing with each other, each version can be considered as a development environment and you can have different versions of python libraries and modules all isolated from one another
Yes it's very important. For example without a virtualenv, if you're
working on an open source project that uses django 1.5
but locally on
your machine, you installed django 1.9
for other personal projects.
It's almost impossible for you to contribute because you'll get a lot of
errors due to the difference in django
versions. If you decide to
downgrade to django 1.5
then you can't work on your personal projects
anymore because they depend on django 1.9
.
A virtualenv handles all this for you by enabling you to create seperate virtual (development) environments that aren't tied to each other and can be activated and deactivated easily when you're done. You can also have different versions of python
You're not forced to but you should, it's as easy as:
virtualenv newenv
cd newenv
source bin/activate # The current shell uses the virtual environment
Moreover it's very important for testing, lets say you want to port
a django web app from 1.5 to 1.9, you can easily do that by creating
different virtualenv's and installing different versions of django.
it's impossible to do this without uninstalling one version (except
you want to mess with sys.path
which isn't a good idea)
While I can't directly describe the experience with Django and virtual environments, I suspect its pretty similar to how I have been using Flask and virtualenv.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With