poetry: pip installs numpy but poetry does not

Issue

Hi – I’ve seen a bunch of other issues related to numpy, and know it’s a numpy problem on Big Sur EXCEPT i think i’ve done everything right (in re upgrading), and I still get the following - works when I install numpy directly via pip, but fails from poetry. What should I do here?

 pip install numpy                                 
Collecting numpy
  Downloading numpy-1.20.2-cp38-cp38-macosx_10_9_x86_64.whl (16.0 MB)
     |████████████████████████████████| 16.0 MB 1.1 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.20.2


 poetry add numpy                          
Using version ^1.20.2 for numpy

Updating dependencies
Resolving dependencies... (0.2s)

Package operations: 1 install, 0 updates, 0 removals

  • Installing numpy (1.20.2): Failed

  EnvCommandError


[...]

 -> /private/var/folders/f_/6hhd4mmx7z734psc7n4m7ygc0000gn/T/pip-req-build-7cbwqfze/build/temp.macosx-11-x86_64-3.9/ccompiler_opt_cache_clib.py
    ----------------------------------------
    ERROR: Failed building wheel for numpy
  Failed to build numpy
  ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly


  at /usr/local/lib/python3.9/site-packages/poetry/utils/env.py:1074 in _run
      1070│                 output = subprocess.check_output(
      1071│                     cmd, stderr=subprocess.STDOUT, **kwargs
      1072│                 )
      1073│         except CalledProcessError as e:
    → 1074│             raise EnvCommandError(e, input=input_)
      1075│
      1076│         return decode(output)
      1077│
      1078│     def execute(self, bin, *args, **kwargs):

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 11
  • Comments: 15 (2 by maintainers)

Most upvoted comments

I changed the python version in my pyproject.toml and it worked for me (MacOS Big Sur + Poetry version 1.1.12 + python 3.9.9):

[tool.poetry.dependencies]
python = ">=3.9,<3.11"

Is there any update to this? I’m currently able to install numpy using pip (v21.3) but not poetry. I think this might be a pip version issue, as poetry is using 21.2.4, and stackoverflow seems to have some answers indicating that general numpy installation issues were resolved with a newer pip version.

I ran into the same issue on Windows 10 with python=3.10. The solution was to use pip to install the packages and then add them with poetry, which just added them to pyproject.toml, therefore:

poetry run pip install numpy scikit-learn
poetry add numpy scikit-learn

With poetry 1.1.12 it works (it uses pip 21.3.1)

I’m on 1.1.12 and I run into this too.

I ran into the same issue on Windows 10 with python=3.10. The solution was to use pip to install the packages and then add them with poetry, which just added them to pyproject.toml, therefore:

poetry run pip install numpy scikit-learn
poetry add numpy scikit-learn

this worked for me on MacOs M1 as well

I ran into the same issue on OSX. For me the solution was that I needed to build the BLAS and LAPACK libraries using Brew and then link them back to the Poetry build environment as explained in this Stackoverflow question: https://stackoverflow.com/a/70880741/1216837

@clintonroy But does it? In fact, I had to resolve for all those constraints myself with those markers, which was straight forward just using pip in the venvs, and therefore should be very doable for an automated tool. And that’s exactly what I was expecting poetry would do for me. Instead it just tells me my constraints were unresolvable, which is just not true.