Dylan Siegler Dylan Siegler - 11 months ago 41
Python Question

What Should the Structure of virtualenv Environment Look Like

This is one of my first times really using

and when I first activated it I was (and am) a bit confused about where my actual project (like the code) should go. Currently (after making and activating the
) this is what my project looks like in

Project Name
|-project-name <= I called my virtualenv project-name
|-Lots of stuff here
|-Lots of stuff here
|-Lots of stuff here

In this environment, where should I put my actual code?

Answer Source

When you activate a virtual env using virutalenv env, env (where all of your dependencies will be installed), sits at the top of your root directory. Let's say you use Django to create a project, you would then follow these steps:

  1. Type source env/bin/activate to activate virtual environment
  2. Type pip install django to install Django
  3. Type django-admin startproject my-example-proj, which will install Django in your root directory

You should now how two directories: env and my-example-proj. You project never goes inside the env directory. That's where you install dependencies using pip.