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?
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:
mkdir project-name
.cd project-name
.virtualenvwrapper env
.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
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:
source env/bin/activate
to activate virtual environmentpip install django
to install Djangodjango-admin startproject my-example-proj
, which will install Django in your root directoryYou 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With