Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Virtualenv's are great for managing dependencies. Config files (or settings files) are very good for managing variable differences between environments. (e.g db location e.tc)</p> <p>The python hitchhikers guide is very good and worth a 20 min read. <a href="http://docs.python-guide.org/en/latest/index.html" rel="nofollow">http://docs.python-guide.org/en/latest/index.html</a></p> <p>See this section on virtual envs.</p> <p><a href="http://docs.python-guide.org/en/latest/dev/virtualenvs/" rel="nofollow">http://docs.python-guide.org/en/latest/dev/virtualenvs/</a></p> <p>If you just want to use different home or env mode variables you could just set it before you run the python code.</p> <pre><code> PROD_MODE=PROD python example.py </code></pre> <p>example.py would then look for the PROD_MODE variable like so.</p> <pre><code>import os print os.environ['PROD_MODE'] </code></pre> <p>So do you need a virtualenv?</p> <p>I would strongly recommend it. So you have Django working and you've imported some other libraries (i also strongly recommend pip) and everything is working on your machine. Your path is setup and your code can resolve to the code using PATH and PYTHON_PATH. Brilliant!</p> <p>Now you come to deploy on another machine (maybe aws, an linux server or similar) or a fellow developer wants to help code on your project. How do they make sure the env on there machine is setup just the same as yours and how do you ensure you deploy with the same env you tested all your shinny new code with? A virtualenv does this for you! You just port or recreate the virtual env on the new machine any everything works just as tested/built.</p> <p>In short a virtual env helps you ensure you don't have a headache in remembering all your imports, installs and path settings when you release/deploy code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload