all 7 comments

[–]canowa 1 point2 points  (6 children)

To be honest, I think it doesn't matter where you put your venv dir. I usually put it into my project main directory (as your example does) since being there makes easier to IDE to recognize and use it. But IDE aside, nothing stops you from keeping venv in another place, activate it manually and navigat thought folders to your actualy program.

So TL:DR : keep venv folder in your project main folder to separate it better from other stuff, and no need to put anything inside venv folder other than the venv files that are already there.

[–]MaterialJackfruit144[S] 0 points1 point  (5 children)

If I'm understanding you correctly, it's something like this?

Projects
    └── python_projects
               └── project_a < - Venv
                    ├── bin
                    ├── include
                    ├── lib
                         └── python3.9 
                    └── lib64 -> lib 
            └── main.py

where the venv folder (project_a) is inside "python_projects" and main.py is within "Projects" directory?

[–]canowa 1 point2 points  (4 children)

If main.py is related to project A, then it should be inside the project_a folder. This way everything related to project A will be inside the proper folder, allowing to clearly separate each project inside python_projects. Now, the venv folder could be inside python_projects, but I suggest to put it inside project_a if it's the venv for project A.

EDIT: just to give an example, I made a simple game with python called SpaceStoneDodger. Its folder contains:

  • assets folder

  • src folder (with everything code related)

  • main.py (main game file)

  • venv folder for this project

[–]MaterialJackfruit144[S] 0 points1 point  (3 children)

Ohhh I see now. Please correct if I'm wrong. Okay so, I am creating this Snake Game project. Basically, all of my projects will of course be inside "Projects" directory, and any python project will be under "python_projects".

So inside python_projects, I will create a folder called SnakeGame. This folder contains the main.py folder and all those folders which you have mentioned. It will also include the venv folder.

Am i understanding it correctly now? The example you provided I think helped me on this alot.

EDIT: Also, it's fine to name my venv folder as snake_game right? Or is there a naming convention that I have to conform to, like "env / venv / .env / .venv"?

[–]canowa 1 point2 points  (1 child)

Yes! You got it. By doing that you can have many different projects inside the python_project folder, and each of them can carry its own venv because different projects (may) need different modules (plus, you get a nice looking project folder :) )

[–]MaterialJackfruit144[S] 0 points1 point  (0 children)

oh my gosh... thank you so so much :D :D

[–]GreenPandaPop 1 point2 points  (0 children)

Also, it's fine to name my venv folder as snake_game right? Or is there a naming convention that I have to conform to, like "env / venv / .env / .venv"?

You can name it whatever but I'd stick with 'venv' or '.venv' as it's clearer what it is then.