Search code examples
pythonpipvirtualenvpython-poetry

Difference between 1. Poetry add <package> vs 2. a) Poetry shell then b) pip install <package>


I am wondering what is the difference when we do poetry add <package> vs spawning a shell in the virtual env using poetry shell and then installing using pip pip install <package>. One difference I can spot is pip install method does not add the package to "pyproject.toml" file. However, after doing the pip install from the poetry shell, when I do poetry add <same package>, poetry does recognize the package has already been installed and it does add the package information in the dependency file.

The reason for doing this is few packages do not work with the poetry add method on my system but work with the pip install method. Hence wanted to get a better understanding of what is happening under the hood.


Solution

  • "poetry add " is used in place of "pip install "; "poetry shell" is the command used to activate the virtual environment...

    here is some good reading on virtual environments (and how to use poetry specifically):