Search code examples
pythonpython-venvpython-poetry

Packages installed using poetry are not available inside `poetry shell`


Packages installed using poetry install are available in poetry run but not in poetry shell.

$ poetry add {package}
$ poetry install
# this works
$ poetry run python
> import {package}
# ...but not this
$ poetry shell
$ python
> import {package}

Am I doing something wrong or misunderstanding what poetry shell does?
I thought it would activate the virtual environment setup by poetry.
poetry --version prints Poetry (version 1.5.1)


Solution

  • As suggested by @Brian61354270's comment, I checked the Python executable that was being used inside poetry shell using type python. Turns out it was pyenv that was overriding the python path whenever I open a new shell. I was able to fix this problem by removing the pyenv config file and letting poetry control the Python version.