最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Poetry "no module named numpy" when installing from existing project - Stack Overflow

programmeradmin4浏览0评论

I have installed Poetry via the official shell script. I have by now also reinstalled it several times. which poetry returns /home/myuser/.local/bin/poetry. The Poetry version is 2.1.1. The python versions are managed by Pyenv.

When I set up an empty project, I can use poetry without any issues. But if I try to do poetry install on an existing project that I pull from github, it responds with No module named 'numpy'. This is the response I get no matter which command I try, even poetry --versionreturns the same error.

This has happened on any existing project I have tried. It's not a packaging error - Poetry doesn't get far enough to even try to install packages. I have gone through everything I could find online, it doesn't seem like this error has been discussed before.

I have installed Poetry via the official shell script. I have by now also reinstalled it several times. which poetry returns /home/myuser/.local/bin/poetry. The Poetry version is 2.1.1. The python versions are managed by Pyenv.

When I set up an empty project, I can use poetry without any issues. But if I try to do poetry install on an existing project that I pull from github, it responds with No module named 'numpy'. This is the response I get no matter which command I try, even poetry --versionreturns the same error.

This has happened on any existing project I have tried. It's not a packaging error - Poetry doesn't get far enough to even try to install packages. I have gone through everything I could find online, it doesn't seem like this error has been discussed before.

Share Improve this question asked Mar 17 at 10:57 DarinaDarina 1,63210 silver badges19 bronze badges 3
  • Any existing project – Darina Commented Mar 17 at 11:40
  • Yes, it does not matter if numpy is a dependency or not. poetry --version also breaks and that's not reliant on anything contained in the pyproject.toml file – Darina Commented Mar 17 at 13:00
  • There are no other errors. I have installed poetry in both those ways and also with the official installer script. I have tried reinstalling poetry several times in different ways now. – Darina Commented Mar 17 at 15:39
Add a comment  | 

1 Answer 1

Reset to default 0

Solved - the issue was never directly with poetry or with pyproject.toml. Every repo I tried to install also contained a build.py file that imported numpy first. Poetry runs this before anything else, hence the error was generated. The solution was to modify build.py so that it does not import at the top level.

发布评论

评论列表(0)

  1. 暂无评论