Poetry + VSCode

Windows and Mac: Set your env right!

Shobeir Seddington
2 min readOct 27, 2024
Photo by CONNOR BOTTS on Unsplash

This is strictly following this awesome guide. I just added a couple of preliminary steps and some windows/powershell versions of the commands.

Step 1. Install Python, make sure to add it to the path

Step 2. Install PipX:

python -m pip install --user pipx
python -m pipx ensurepath

Step 3: Install poetry:

pipx install poetry

A. Create a github managed repository

B. Open VS code

C. Open terminal

D. Go to code root:

poetry init

E. follow the wizard and create the project.

F. Make a new project subdirectory and call it myapp.

G. Make sure the pyproject.toml reads:

[tool.poetry]
name="myapp"

H. Create a main.py into the myapp subdirectory

(in windows with powershell):

New-Item -ItemType File -Path .\myapp\main.py

I. Create a simple program like:

if __name__=="__main__":
print("Happy Birthday")

J. Type Poetry Install (fingers crossed, no errors). I had to change my python interpretor version in VScode to reflect the latest version that I had installed.

K. Type poetry shell and you should be in the environment you created.

poetry install

L. Type:

poetry add numpy

M. Adding it into VS Code:

poetry env info

N. Add the path to the clipboard: Windows:

poetry env info --path | Set-Clipboard

Mac:

poetry env info --path |pbcopy

Open command palette (CNTRL + SHIFT + P) and select add manually

O. OMG, just choose the right interpreter and things should be fine!

--

--

Shobeir Seddington
Shobeir Seddington

Written by Shobeir Seddington

Quantum Roots, Data Dreams: A Journey Through Science, Life, and the Art of Possibilities. "Opinions expressed are solely my own."

No responses yet