Dylan Siegler Dylan Siegler - 3 months ago 13
Python Question

What Should the Structure of virtualenv Environment Look Like

This is one of my first times really using

virtualenv
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
virtualenv
) this is what my project looks like in
PyCharm
:

Project Name
|-project-name <= I called my virtualenv project-name
|-bin
|-Lots of stuff here
|-include
|-Lots of stuff here
|-lib
|-Lots of stuff here
|-.Python
|-pip-selfcheck.json


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

Answer

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.