I'm using poetry for dependency management. I have poetry.lock
file in my repository & I used it to install the dependencies using poetry install
. It created a virtualenv and is activated.
# poetry env list
python-tricks-sYsxS0XS-py3.7 (Activated)
When I try to add numpy
as a dependency, it gives ValueError: Package numpy is already present
. However, when I try to import the numpy package in a shell or run a script containing numpy in it's import statements, it throws ModuleNotFoundError
.
What I don't understand is, if the package is already present then why is it throwing ModuleNotFoundError
?
Summary
poetry install -> Installs dependencies & created a virtualenv
poetry env list -> Sanity check: python-tricks-sYsxS0XS-py3.7 (Activated)
poetry add numpy -> [ValueError]: Package numpy is already present
poetry scripty.py -> script.py imports numpy gives ModuleNotFoundError
Can someone provide an explanation for this behaviour and possible solution?
Note:- I have installed python using asdf
As I mentioned I was using
asdf
. It has a plugin for poetry as well - https://github.com/crflynn/asdf-poetryUsing that solved the issue-
Poetry then works alright -