Python Forum
Virtual Environments - Organization (VS Code)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Virtual Environments - Organization (VS Code)
#1
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.
Reply
#2
You can put the virtual environments anywhere.
Reply
#3
(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?
Reply
#4
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.
Reply
#5
(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.
Reply
#6
How did you make your virtual environment? What is your OS?
Reply
#7
(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?
Reply
#8
SOLVED: python.defaultInterpreterPath located in settings.json

Thanks for the replies.
Reply
#9
(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.
Larz60+ likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#10
Great point. Perhaps my approach is wrong. Still a noob
Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Organization of project directories wotoko 3 419 Mar-02-2024, 03:34 PM
Last Post: Larz60+
  Best practice on using virtual environments in Python bytecrunch 6 806 Feb-14-2024, 03:22 PM
Last Post: snippsat
Question Virtual Environment (using VS Code) Ashcora 4 13,648 Feb-15-2023, 07:17 PM
Last Post: snippsat
  Keeping up with IDEs and Virtual Environments... bytecrunch 7 2,489 Sep-05-2022, 08:04 PM
Last Post: snippsat
  I don't understand pip and environments snakes 3 1,230 Jul-31-2022, 08:17 PM
Last Post: snakes
  Use different Anaconda environments on Linux Mint and Spyder StaLLoNe_CoBRa 0 1,877 Jan-20-2021, 03:12 AM
Last Post: StaLLoNe_CoBRa
  pip and venv virtual environments soupworks 2 2,279 Dec-30-2020, 11:38 PM
Last Post: soupworks
  Virtual Assistant code is looping back in python ShishirModi 1 2,518 Oct-13-2020, 08:04 AM
Last Post: Nickd12
  Virtual Environments pneveux 1 1,821 Apr-04-2019, 09:15 PM
Last Post: Larz60+
  Embedding, windows, and virtual environments mariofutire 0 3,028 Sep-14-2018, 10:30 AM
Last Post: mariofutire

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020