Where should virtualenvs go in production

0 votes
When using virtualenv (or virtualenvwrapper), the recommended practice is to group all your virtual environments together. For example in ~/.virtualenvs

But, I've noticed in reading a number of articles on deploying Django applications, that the recommendation seems to be to put your virtual environments somewhere under the root of the individual web application. For example in /srv/www/example.com/venv.

Why and how Would it matter if I went one way or the other? And is one way recommended over another?
Jun 25, 2019 in Python by ana1504.k
• 7,910 points
2,231 views

1 answer to this question.

0 votes

Arguments for grouping in a common folder

  • Cleaner management of multiple venvs on a given machine. Good tools to support checking which are available, adding new ones, purging old ones, etc.
  • More sensible (and more space-efficient) when sharing one or more venvs across more than one project
  • Allows the use of some nice features like auto-completion of venv names

Arguments for keeping with the project

  • Clear relationship between the venv and the project. Eliminates any ambiguity and less error-prone since there's little chance of running the wrong venv for a project (which is not always immediately evident).
  • Makes more sense when there is a one-to-one relationship between venvs and projects
  • May be the preferred approach when working in teams from separate accounts.
  • More straightforward when deploying across identical hosts; (just rsync the whole project). Nothing stopping you from doing this with a venv in a common folder, but it feels more natural to deploy a single tree.
  • Easier to sandbox the whole application.
answered Jun 25, 2019 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

How should I write tests for Forms in Django with Python?

from django.tests import TestCase class MyTests(TestCase): ...READ MORE

answered Nov 20, 2018 in Python by Nymeria
• 3,560 points
1,440 views
0 votes
1 answer

How to run django unit-tests on production database in Python?

In case someone googles here searching for ...READ MORE

answered Nov 28, 2018 in Python by Nymeria
• 3,560 points
1,569 views
0 votes
1 answer

How can I go about using var == False in Python?

Hi. Simple answer.  All you need to do ...READ MORE

answered Feb 13, 2019 in Python by Nymeria
• 3,560 points
781 views
0 votes
0 answers

where and how can i use PYTHONPATH in python?

is there a particular syntax for this?? READ MORE

Apr 8, 2019 in Python by Waseem
• 4,540 points
625 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 7, 2018 in Python by Priyaj
• 58,020 points
1,696 views
0 votes
1 answer

Crawling after login in Python

You missed a few login data forms, ...READ MORE

answered Sep 14, 2018 in Python by Priyaj
• 58,020 points
870 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,790 points
2,003 views
0 votes
1 answer

How to go to top frame in pdb (python debugger)

You can use a PdbExtension for this. See https://github.com/fschulze/pytest-pdb/pull/5 where ...READ MORE

answered Apr 30, 2019 in Python by SDeb
• 13,300 points
2,122 views
0 votes
1 answer

Deploying Flask on Windows in production

Installing on Windows is kind of like ...READ MORE

answered May 29, 2019 in Python by SDeb
• 13,300 points
3,687 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP