Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should source code be saved when working with virtualenv?

Should I create a directory in my virtualenv and save the source code for that specific project there?

Thanks in advance

like image 277
AnriSonohara Avatar asked Apr 01 '26 05:04

AnriSonohara


1 Answers

You're not required to have them related in any way. As long as your env is activated, it doesn't matter where it is.

But what's usually easiest is:

  • Create an empty directory for your project.
  • Create the virtualenv under that project directory.
  • Put the source in a src directory under that project directory (or, for really simple projects, just drop it in the project directory).

That way you can check the env settings into version control alongside your code, and if you use an auto-venv tool it'll activate the env every time you cd into the project directory, and so on.

As a side note, if you're just learning this stuff today, you might want to consider learning pipenv instead of using raw virtual environments.

like image 200
abarnert Avatar answered Apr 03 '26 19:04

abarnert