Similar to “Pipenv“, “Poetry“ is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
Installation
1 | # Before running make sure you have "Python" installed. |
After running the script, make sure you have the following content in your “~/.zshrc” file, if you’re using “zsh”:
1 | export PATH="$HOME/.poetry/bin:$PATH" |
Project setup
1 | # For a new project: |
Running
1 | # Start the virtual environeent: |
More details can be also found in this post.
Updating Poetry
From here.
1 | poetry self update |
Uninstall Poetry
From here.
1 | # Download the installation script. |
Warning
After upgrading “poetry” and running it I got the following warning message:
1 | > poetry --version |
I googled it and this post gave me some hints. Here are the instructions I did.
1 | # 1. Confirm which directory is used by your "poetry". |
Add wheel dependency in “poetry”
If you have some local “wheel” Python library which you want to use in your “poetry” project, update the “pyproject.toml” file by adding the content like below:
1 | [tool.poetry.dependencies] |
After adding such content, you can run “poetry install” to install the dependencies recursively.
Remove virtual environment
Sometimes if you install some packages by mistaken and want to clear the virtual environment then install it again, you can run the following command(from here) before running “poetry install”:
1 | poetry env remove --all |