<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Parthiv Kativarapu</title>
    <description>The latest articles on DEV Community by Parthiv Kativarapu (@parthiv13).</description>
    <link>https://dev.to/parthiv13</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F346419%2F18f16c2d-c955-401a-ab2f-2d15b6f17667.jpg</url>
      <title>DEV Community: Parthiv Kativarapu</title>
      <link>https://dev.to/parthiv13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/parthiv13"/>
    <language>en</language>
    <item>
      <title>My Go-To Setup: Python Virtual Environments in VS Code for Multiple Projects</title>
      <dc:creator>Parthiv Kativarapu</dc:creator>
      <pubDate>Wed, 14 May 2025 02:31:10 +0000</pubDate>
      <link>https://dev.to/parthiv13/my-go-to-setup-python-virtual-environments-in-vs-code-for-multiple-projects-1j1</link>
      <guid>https://dev.to/parthiv13/my-go-to-setup-python-virtual-environments-in-vs-code-for-multiple-projects-1j1</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Recently, I dove headfirst into the world of Python while building several AWS Lambda functions for a project. These Lambdas, though part of a single repository, each had their own unique set of dependencies managed by Poetry.&lt;br&gt;
Here's a typical project folder structure: &lt;/p&gt;

&lt;p&gt;project-root/&lt;br&gt;
|__ infra&lt;br&gt;
|__ Lambdas&lt;br&gt;
    |__ lambda1&lt;br&gt;
        |__ poetry.toml&lt;br&gt;
    |__ lambda2&lt;br&gt;
        |__ poetry.toml&lt;/p&gt;

&lt;p&gt;As you can imagine, keeping the dependencies isolated for each Lambda was crucial.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: IntelliJ and the Single Virtual Environment
&lt;/h2&gt;

&lt;p&gt;Coming from the Java Programming world, IntelliJ has been my go-to IDE for years (and yes, I have the Ultimate edition!). Naturally, I tried using the Python plugin for this project. However, I quickly hit a problem: IntelliJ seemed to allow the easy activation and setting of only &lt;em&gt;one&lt;/em&gt; virtual environment as the default for the entire project. Switching between environments based on the file I was working on involved multiple clicks – a real context-switching killer and too much of a hassle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: The Magic of VS Code Workspaces!
&lt;/h2&gt;

&lt;p&gt;However, when I opened the project in IntelliJ, I realized that I could activate and set only one of the virtual environment as the default. It needs couple of clicks to change the virtual environment depending on the files. Too much of a hassle. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution!!
&lt;/h2&gt;

&lt;p&gt;While trying to find some solution for this, I stumbled across VS Code Workspaces. It made my life easier. Rather, I should say working in this project setup easier. :p&lt;br&gt;
Add your folders into a workspace, and save it as a workspace. Depending on your working file, VS Code, changes between the different and relevant virtual environments. Easy peezy.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do you create workspace?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open a new VS Code window&lt;/li&gt;
&lt;li&gt;Open your first folder. In our example, navigate to and open the &lt;code&gt;lambda1&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;Go to &lt;code&gt;File&lt;/code&gt; -&amp;gt; &lt;code&gt;Add Folder to Workspace&lt;/code&gt;, add your next folder (e.g., &lt;code&gt;lambda2&lt;/code&gt;). Repeat this for any other relevant project folders.&lt;/li&gt;
&lt;li&gt;Once you've added all the necessary folders, go to, &lt;code&gt;File -&amp;gt; Save Workspace As&lt;/code&gt; save the workspace.&lt;/li&gt;
&lt;li&gt;Now, the magic happens! As you navigate between files within &lt;code&gt;lambda1&lt;/code&gt; and &lt;code&gt;lambda2&lt;/code&gt;, VS Code will automatically detect and switch to the corresponding virtual environment associated with that folder (assuming you have a &lt;code&gt;.venv&lt;/code&gt; folder or have configured the interpreter within that folder's &lt;code&gt;.vscode/settings.json&lt;/code&gt;). You'll likely see the Python interpreter indicator in the VS Code status bar change.&lt;/li&gt;
&lt;li&gt;The next time, use the &lt;code&gt;.workspace&lt;/code&gt; file to open the project in VS Code and all your folders and configurations will be loaded.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Fin.&lt;br&gt;
&lt;strong&gt;What are your experiences with managing multiple virtual environments? Share your tips and tricks in the comments below!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>python</category>
      <category>poetry</category>
    </item>
  </channel>
</rss>
