Python Forum

Full Version: Virtual Environments - Organization (VS Code)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello All,

I have a few questions about organizing my virtual environments using VS code. My thought was to create a few venvs that would meet my needs depending on the common type of projects and related packages. I wanted to store them in one location and keep my project files in another location as opposed to placing a venv in each project folder. For example:

Quote:My_Python_Projects (Main Project Folder)
My_Project_1
-project_1.py
My_Project_2
-project_2.py
My_Project_3
-project_3.py

My_Python_Venvs (Main Venv Folder)
My_Venv_1
-venv_files_folders_1.py
My_Venv_2
-venv_files_folders_2.py
My_Venv_3
-venv_files_folders_3.py
My thinking was that I could then open up a project in VS Code and simply select one of the existing venvs. Is this possible or must I put the venvs in the actually project file each time.

Hope it makes sense. Thanks in advance for any advice.
You can put the virtual environments anywhere.
(Jan-25-2023, 01:56 PM)deanhystad Wrote: [ -> ]You can put the virtual environments anywhere.
Thank you for the quick reply. This may be a VS Code issue but I am not able to select any of the venv in my vent folder as the interpreter for the projects. When I try to select the interpreter path from the new venv it is aliased to the global interpreter / env.

Any thoughts?
What do you select? When selecting the python for a project I burrow down into the venv folder and select the python.exe.

Be aware that when vs code starts up, the first terminal does not run inside the selected virtual environment. I automatically close the first terminal and open another.
(Jan-25-2023, 02:34 PM)deanhystad Wrote: [ -> ]What do you select? When selecting the python for a project I burrow down into the venv folder and select the python.exe.

Be aware that when vs code starts up, the first terminal does not run inside the selected virtual environment. I automatically close the first terminal and open another.
I also burrow down into the venv folder but the python files in there are only aliases to the global install.
How did you make your virtual environment? What is your OS?
(Jan-25-2023, 03:08 PM)deanhystad Wrote: [ -> ]How did you make your virtual environment? What is your OS?

Hi,

I am on MacOS Ventura and I was making the venv from the terminal inside VS Code:
python3 -m venv ~/Documents/Code/Python/venv
source ~/Documents/Code/Python/venv/bin/activate
then I try to select the environment from the VS Code dropdown but it is not available.

I tried both and from the project folder and the main venv folder

Is this correct?
SOLVED: python.defaultInterpreterPath located in settings.json

Thanks for the replies.
(Jan-25-2023, 01:55 PM)JaysonWonder Wrote: [ -> ]My thought was to create a few venvs that would meet my needs depending on the common type of projects and related packages. I wanted to store them in one location and keep my project files in another location as opposed to placing a venv in each project folder.

IMHO shared venvs between common type of projects more or less defies the whole idea of using virtual environments, i.e. to have separate isolated environments for each project with specific version of dependencies/site-packages, that does not interfere with dependencies for other projects.
Great point. Perhaps my approach is wrong. Still a noob
Thanks
Pages: 1 2