I’ve done this maybe five times so far and always forget how to do it. If you want to use the Poetry package manager with VS Code, I hope this helps you out! I followed the instructions by this guru I follow and they worked!
- Create a Github managed repository on your local drive (be sure to have a README.md).
- Open up VS Code.
- Open a Terminal.
- Within your root code directory type
poetry initand follow the maze of menus. - You need to make a new project subdirectory, call it
myapp - In your
pyproject.tomlchange the 2nd line where it saysname = <blah blah>to instead read:[tool.poetry]
name = "myapp" - Next, put a new file
main.pyinto the new subdirectory - In the
main.pyyou can have a program like the following:if __name__ == "__main__":
print("Happy Birthday!") - Type
poetry installand pray that you don’t get any really bad error messages. - If this really works the right way, type
poetry shelland you should be in the environment you created. I ran into an error around but it still seemed to work (this time). - Type
exitto get back to where you came from - To learn a few more poetry commands:
- poetry add [package-name]
- poetry remove [package-name]
- poetry self:update (to update poetry itself)
Wire it into VS Code
Type poetry env info which for me looks like:
(base) ➜ dit2024-llama-db git:(main) ✗ poetry env info
Virtualenv
Python: 3.10.13
Implementation: CPython
Path: /Users/maeda/Documents/GitHub/dit2024-llama-db/.venv
Executable: /Users/maeda/Documents/GitHub/dit2024-llama-db/.venv/bin/python
Valid: True
System
Platform: darwin
OS: posix
Python: 3.10.13
Path: /Users/maeda/.pyenv/versions/3.10.13
Executable: /Users/maeda/.pyenv/versions/3.10.13/bin/python3.10
Then we want to:
% poetry env info --path
/Users/maeda/Documents/GitHub/dit2024-llama-db/.venv
To then make it addable to your Python environment list on MacOS do:
% poetry env info --path | pbcopy
You then want to bring up the command palette to select your Python Interpreter, and add one manually:

Plop the path you’ve got in your clipboard into Enter interpreter path …
As a result, your terminal and subsequent Python notebooks will use this Poetry environment. Phew.
WAIT: That’s not true. You need to select the environment correctly as it will NOT recommend the right environment from the get go. Be sure to pick the one that’s in your .venv local to your ./ so you get the right stuff from poetry.

You must be logged in to post a comment.