Install Visual Code and Create Virtual Environmnet

  1. Install Visual Code: https://code.visualstudio.com/
  2. Install the Python Extension(in case this was not installed when installing Visual Code)
  3. Open VS Code.
  4. Click the Extensions icon on the left sidebar (it looks like four squares).
  5. Search for "Python" and install the one provided by Microsoft.
  6. Open Your Project Folder
  7. Create a folder on your computer (e.g., Documents/my_project).
  8. In VS Code, go to File > Open Folder and select that folder.
  9. Open a new Terminal by going to Terminal > New Terminal at the top menu.
  10. Create and Activate the Virtual Environment
  11. In the terminal window at the bottom of your screen, type these commands:                          python -m venv .venv
  12. Wait a moment; you'll see a folder named .venv appear in your file explorer.
  13. Activate the environment:
  14. .venv\Scripts\activate
  15. Note: You should now see (.venv) in green text at the start of your command line.
  16. Install the libraries in the Virtual Environment


Note:

Windows sets the default execution policy to Restricted to prevent malicious scripts from running in the background. Since the .venv\Scripts\Activate.ps1 file is technically a script, Windows blocks it until you explicitly tell it that you trust the scripts in your current process.


To make this change permanent so you never have to deal with that error again, you need to change the Execution Policy for your Current User rather than just the "Process."

Here is how to do it safely:

1. Open PowerShell as Administrator

  1. Click the Windows Start button.
  2. Type PowerShell.
  3. Right-click on Windows PowerShell and select Run as Administrator. (This is important because changing system-wide policies requires extra permissions).

2. Run the Permanent Command

In the blue window that opens, type (or paste) the following command and press Enter:

PowerShell


Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

3. Confirm the Change

  • PowerShell will ask for confirmation.
  • Type Y (for Yes) and press Enter.

Why this is the "Sweet Spot" for Security

By setting it to RemoteSigned for the CurrentUser :

  • Local scripts: Any script you create on your own computer (like the .venv activation script) will run freely.
  • Internet scripts: Any script downloaded from the internet must be "signed" by a trusted publisher to run, which keeps you protected from most malicious files.

Pro-Tip: Let VS Code Auto-Activate

Now that the permissions are fixed, VS Code can actually do the work for you.

  1. In VS Code, press Ctrl + Shift + P .
  2. Type "Python: Select Interpreter".
  3. Select the one that points to your virtual environment (it should look like .\.venv\Scripts\python.exe ).
  4. Now, whenever you open a new terminal in this project folder, VS Code will automatically run the activation script for you! You’ll see (.venv) pop up without you typing a single word.


By Flaubert Tchouangwa August 24, 2025
Install Python and create virtual environment Here’s how you can create a Python virtual environment step by step: