Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 959
Dylan Siegler Avatar asked Aug 21 '16 14:08

Dylan Siegler


2 Answers

I don't recommend to put your project to virtualenv folder. I think you should do it in this way:

Do it in terminal if you're using Linux:

  1. mkdir project-name.
  2. cd project-name.
  3. virtualenvwrapper env.
  4. source env/bin/activate.

So you will have project-name folder where you will have all files according to your project + virtualenv folder called env.

If you don't have virtualenvwrapper, then just install it using apt-get:

sudo apt-get install virtualenvwrapper

like image 157
turkus Avatar answered Nov 11 '22 19:11

turkus


When you activate a virtual env using virtualenv 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.

like image 20
joshlsullivan Avatar answered Nov 11 '22 20:11

joshlsullivan