Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip installs numpy but poetry does not #3894

Closed
3 tasks done
aronchick opened this issue Apr 8, 2021 · 15 comments
Closed
3 tasks done

pip installs numpy but poetry does not #3894

aronchick opened this issue Apr 8, 2021 · 15 comments
Labels
kind/question User questions (candidates for conversion to discussion)

Comments

@aronchick
Copy link

aronchick commented Apr 8, 2021

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):
@aronchick aronchick added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Apr 8, 2021
@mingchuno
Copy link

mingchuno commented May 9, 2021

Same issue here. Also link to #3627

@NickAnderegg
Copy link

So I may have information that could narrow down the specific numpy issues. I created three directories, each with an identical pyproject.toml:

[tool.poetry]
name = "demo"
version = "0.1.0"
description = ""
authors = ["Nick Anderegg <nick@anderegg.io>"]

[tool.poetry.dependencies]
python = ">=3.8,<3.10"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

In each directory, I ran a separate command to install something that has numpy (in this case, scipy):

~/tmp/poetry_numpy_tests/pip_install @ 10:18:31 PM
❯ poetry run pip3 install scipy

Creating virtualenv demo-J2g__jnb-py3.9 in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs
Collecting scipy
  Using cached scipy-1.7.1-cp39-cp39-macosx_10_9_x86_64.whl (32.8 MB)
Collecting numpy<1.23.0,>=1.16.5
  Using cached numpy-1.21.2-cp39-cp39-macosx_10_9_x86_64.whl (17.0 MB)
Installing collected packages: numpy, scipy
Successfully installed numpy-1.21.2 scipy-1.7.1
WARNING: You are using pip version 21.0.1; however, version 21.2.4 is available.
You should consider upgrading via the '/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-J2g__jnb-py3.9/bin/python -m pip install --upgrade pip' command.

 10:18:44 PM ❯
~/tmp/poetry_numpy_tests/python_pip @ 10:19:36 PM
❯ poetry run python -m pip install scipy

Creating virtualenv demo-4WzZmSBb-py3.9 in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs
Collecting scipy
  Using cached scipy-1.7.1-cp39-cp39-macosx_10_9_x86_64.whl (32.8 MB)
Collecting numpy<1.23.0,>=1.16.5
  Using cached numpy-1.21.2-cp39-cp39-macosx_10_9_x86_64.whl (17.0 MB)
Installing collected packages: numpy, scipy
Successfully installed numpy-1.21.2 scipy-1.7.1
WARNING: You are using pip version 21.0.1; however, version 21.2.4 is available.
You should consider upgrading via the '/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-4WzZmSBb-py3.9/bin/python -m pip install --upgrade pip' command.

 10:19:49 PM ❯

Notice in each of the above cases, it took less than 15 seconds to fully install scipy in a fresh venv. Now when I try to add it via poetry, it takes over five minutes for the install to fail. Is it... trying to build it totally from scratch from some non-standard source?

~/tmp/poetry_numpy_tests/poetry_add @ 10:12:40 PM
❯ poetry add scipy

Creating virtualenv demo-SJ17AL5n-py3.9 in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs
Using version ^1.7.1 for scipy

Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 2 installs, 0 updates, 0 removals

  • Installing numpy (1.21.2)
  • Installing scipy (1.7.1): Failed

  EnvCommandError

  Command ['/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/bin/pip', 'install', '--no-deps', 'file:///Users/nickanderegg/Library/Caches/pypoetry/artifacts/47/9d/89/31f1fcd79c1d043c8ea0ac88c687e9828dc6d07d2a83f42219d8494328/scipy-1.7.1.tar.gz'] errored with the following return code 1, and output:
  Processing /Users/nickanderegg/Library/Caches/pypoetry/artifacts/47/9d/89/31f1fcd79c1d043c8ea0ac88c687e9828dc6d07d2a83f42219d8494328/scipy-1.7.1.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: still running...
      Preparing wheel metadata: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/bin/python /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/tmpzqx_91eg
           cwd: /private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-req-build-rpp_yhya
      Complete output (183 lines):
      setup.py:490: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-modern-metadata-tg83lqya'), proceeding with generating Cython sources and expanding templates
        warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
      Running from SciPy source directory.
      Running scipy/linalg/_generate_pyx.py
      Running scipy/special/_generate_pyx.py
      Running scipy/stats/_generate_pyx.py
      Processing scipy/cluster/_vq.pyx
      Processing scipy/cluster/_optimal_leaf_ordering.pyx
      Processing scipy/cluster/_hierarchy.pyx
      Processing scipy/ndimage/src/_cytest.pyx
      Processing scipy/ndimage/src/_ni_label.pyx
      Processing scipy/linalg/cython_lapack.pyx
      Processing scipy/linalg/_matfuncs_sqrtm_triu.pyx
      Processing scipy/linalg/_solve_toeplitz.pyx
      Processing scipy/linalg/cython_blas.pyx
      Processing scipy/linalg/_decomp_update.pyx.in
      Processing scipy/optimize/_group_columns.pyx
      Processing scipy/optimize/_bglu_dense.pyx
      Processing scipy/optimize/_trlib/_trlib.pyx
      Processing scipy/optimize/_highs/cython/src/_highs_constants.pyx
      Processing scipy/optimize/_highs/cython/src/_highs_wrapper.pyx
      Processing scipy/optimize/_lsq/givens_elimination.pyx
      Processing scipy/optimize/cython_optimize/_zeros.pyx.in
      Processing scipy/io/matlab/mio_utils.pyx
      Processing scipy/io/matlab/streams.pyx
      Processing scipy/io/matlab/mio5_utils.pyx
      Processing scipy/_lib/_ccallback_c.pyx
      Processing scipy/_lib/_test_deprecation_def.pyx
      Processing scipy/_lib/_test_deprecation_call.pyx
      Processing scipy/_lib/messagestream.pyx
      Processing scipy/special/_ufuncs_cxx.pyx
      Processing scipy/special/cython_special.pyx
      Processing scipy/special/_ellip_harm_2.pyx
      Processing scipy/special/_comb.pyx
      Processing scipy/special/_test_round.pyx
      Processing scipy/special/_ufuncs.pyx
      Processing scipy/fftpack/convolve.pyx
      Processing scipy/interpolate/interpnd.pyx
      Processing scipy/interpolate/_bspl.pyx
      warning: _cython_special_custom.pxi:9:8: Unreachable code
      warning: _cython_special_custom.pxi:13:4: Unreachable code
      warning: _cython_special_custom.pxi:21:8: Unreachable code
      warning: _cython_special_custom.pxi:25:4: Unreachable code
      warning: _cython_special_custom.pxi:33:8: Unreachable code
      warning: _cython_special_custom.pxi:37:4: Unreachable code
      warning: _cython_special_custom.pxi:45:8: Unreachable code
      warning: _cython_special_custom.pxi:49:4: Unreachable code
      Processing scipy/interpolate/_ppoly.pyx
      Processing scipy/sparse/_csparsetools.pyx.in
      Processing scipy/sparse/csgraph/_shortest_path.pyx
      Processing scipy/sparse/csgraph/_traversal.pyx
      Processing scipy/sparse/csgraph/_flow.pyx
      Processing scipy/sparse/csgraph/_tools.pyx
      Processing scipy/sparse/csgraph/_matching.pyx
      Processing scipy/sparse/csgraph/_reordering.pyx
      Processing scipy/sparse/csgraph/_min_spanning_tree.pyx
      Processing scipy/spatial/ckdtree.pyx
      Processing scipy/spatial/_voronoi.pyx
      Processing scipy/spatial/_hausdorff.pyx
      Processing scipy/spatial/qhull.pyx
      Processing scipy/spatial/transform/rotation.pyx
      Processing scipy/signal/_max_len_seq_inner.pyx
      Processing scipy/signal/_peak_finding_utils.pyx
      Processing scipy/signal/_upfirdn_apply.pyx
      Processing scipy/signal/_spectral.pyx
      Processing scipy/signal/_sosfilt.pyx
      Processing scipy/stats/_stats.pyx
      Processing scipy/stats/_qmc_cy.pyx
      Processing scipy/stats/_sobol.pyx
      Processing scipy/stats/biasedurn.pyx
      Processing scipy/stats/_boost/src/beta_ufunc.pyx
      Processing scipy/stats/_boost/src/nbinom_ufunc.pyx
      Processing scipy/stats/_boost/src/binom_ufunc.pyx
      Cythonizing sources
      lapack_opt_info:
      lapack_mkl_info:
      customize UnixCCompiler
        libraries mkl_rt not found in ['/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      openblas_lapack_info:
        libraries openblas not found in ['/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      openblas_clapack_info:
        libraries openblas,lapack not found in ['/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      flame_info:
        libraries flame not found in ['/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      atlas_3_10_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries tatlas,tatlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries lapack_atlas not found in /usr/local/lib
        libraries tatlas,tatlas not found in /usr/local/lib
        libraries lapack_atlas not found in /usr/lib
        libraries tatlas,tatlas not found in /usr/lib
      <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
        NOT AVAILABLE

      atlas_3_10_info:
        libraries lapack_atlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries satlas,satlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries lapack_atlas not found in /usr/local/lib
        libraries satlas,satlas not found in /usr/local/lib
        libraries lapack_atlas not found in /usr/lib
        libraries satlas,satlas not found in /usr/lib
      <class 'numpy.distutils.system_info.atlas_3_10_info'>
        NOT AVAILABLE

      atlas_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries ptf77blas,ptcblas,atlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries lapack_atlas not found in /usr/local/lib
        libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
        libraries lapack_atlas not found in /usr/lib
        libraries ptf77blas,ptcblas,atlas not found in /usr/lib
      <class 'numpy.distutils.system_info.atlas_threads_info'>
        NOT AVAILABLE

      atlas_info:
        libraries lapack_atlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries f77blas,cblas,atlas not found in /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib
        libraries lapack_atlas not found in /usr/local/lib
        libraries f77blas,cblas,atlas not found in /usr/local/lib
        libraries lapack_atlas not found in /usr/lib
        libraries f77blas,cblas,atlas not found in /usr/lib
      <class 'numpy.distutils.system_info.atlas_info'>
        NOT AVAILABLE

      accelerate_info:
        NOT AVAILABLE

      lapack_info:
        libraries lapack not found in ['/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      /private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-build-env-2krl1upf/overlay/lib/python3.9/site-packages/numpy/distutils/system_info.py:1748: UserWarning:
          Lapack (http://www.netlib.org/lapack/) libraries not found.
          Directories to search for the libraries can be specified in the
          numpy/distutils/site.cfg file (section [lapack]) or by setting
          the LAPACK environment variable.
        return getattr(self, '_calc_info_{}'.format(name))()
      lapack_src_info:
        NOT AVAILABLE

      /private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-build-env-2krl1upf/overlay/lib/python3.9/site-packages/numpy/distutils/system_info.py:1748: UserWarning:
          Lapack (http://www.netlib.org/lapack/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [lapack_src]) or by setting
          the LAPACK_SRC environment variable.
        return getattr(self, '_calc_info_{}'.format(name))()
        NOT AVAILABLE

      Traceback (most recent call last):
        File "/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
          main()
        File "/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-build-env-2krl1upf/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 166, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-build-env-2krl1upf/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 258, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-build-env-2krl1upf/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 150, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 629, in <module>
          setup_package()
        File "setup.py", line 625, in setup_package
          setup(**metadata)
        File "/private/var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/pip-build-env-2krl1upf/overlay/lib/python3.9/site-packages/numpy/distutils/core.py", line 135, in setup
          config = configuration()
        File "setup.py", line 528, in configuration
          raise NotFoundError(msg)
      numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found. Note: Accelerate is no longer supported.
      To build Scipy from sources, BLAS & LAPACK libraries need to be installed.
      See site.cfg.example in the Scipy source directory and
      https://docs.scipy.org/doc/scipy/reference/building/index.html for details.
      ----------------------------------------
  WARNING: Discarding file:///Users/nickanderegg/Library/Caches/pypoetry/artifacts/47/9d/89/31f1fcd79c1d043c8ea0ac88c687e9828dc6d07d2a83f42219d8494328/scipy-1.7.1.tar.gz. Command errored out with exit status 1: /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/bin/python /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/tmpzqx_91eg Check the logs for full command output.
  ERROR: Command errored out with exit status 1: /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/bin/python /Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/81/gn260m8d5011n2y3m_wcjc7w0000gn/T/tmpzqx_91eg Check the logs for full command output.
  WARNING: You are using pip version 21.0.1; however, version 21.2.4 is available.
  You should consider upgrading via the '/Users/nickanderegg/Library/Caches/pypoetry/virtualenvs/demo-SJ17AL5n-py3.9/bin/python -m pip install --upgrade pip' command.


  at ~/.poetry/lib/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):


Failed to add packages, reverting the pyproject.toml file to its original content.

 10:17:21 PM ❯

@s-bessey
Copy link

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.

@Jubijub
Copy link

Jubijub commented Jan 2, 2022

With poetry 1.1.12 it works (it uses pip 21.3.1)

@cnpryer
Copy link

cnpryer commented Jan 27, 2022

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.

@asyafEvinced
Copy link

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"

@acviana
Copy link

acviana commented Mar 5, 2022

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

@felipewhitaker
Copy link

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

@007vasy
Copy link

007vasy commented Jun 28, 2022

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

@neersighted
Copy link
Member

This is a common issue with NumPy and not a Poetry issue per-se. What is happening is that you have specified a wider Python range than the NumPy version that currently supports your Python version supports with built wheels. As such, you are attempting to compile from source and either need to provide NumPy's build dependencies, or pick a version based on wheel availability (and NumPy's support matrix at https://numpy.org/neps/nep-0029-deprecation_policy.html).

In essence, you should poetry add numpy>=<version with wheels for my preferred Python version> and Poetry will let you know if your Python constraint is causing issues.

If you're having problems, I'd suggest creating a Discussion or joining Discord -- this is going to be a configuration/usage problem and not a bug, so those are more appropriate venues. It would be nice to work on building a FAQ entry for NumPy as well as it's not the only package with strict version requirements.

@neersighted neersighted added kind/question User questions (candidates for conversion to discussion) and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 5, 2022
@J3ronimo
Copy link

J3ronimo commented May 17, 2023

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 didn't work for me unfortunately.
While poetry run pip install numpy will happily install numpy 1.24.3, poetry add numpy afterwards (or before that) will refuse to do anything. The error message says

The current project's Python requirement (>=3.7,<4.0) is not compatible with some of the required packages Python requirement:
  - numpy requires Python >=3.8, so it will not be satisfied for Python >=3.7,<3.8

Because no versions of numpy match >1.24.3,<2.0.0
 and numpy (1.24.3) requires Python >=3.8, numpy is forbidden.
So, because {{myproject}} depends on numpy (^1.24.3), version solving failed.

The last line is actually false. myproject depends on numpy, but not on that specific version, which I never specified anywhere (poetry add numpy). So from my understanding, any older numpy version that is compatible with the rest of my other requirements (only python=^3.7 so far) should be good here.

But even if poetry insists on using numpy=^1.24.3 - the Python3.9 in my venv is in fact compatible with that! That's exactly the version that pip used when asked to install numpy. So there is definitely (at least) this one obvious solution to dependency resolution, in contrast to what poetry claims.

Maybe I am missing something here. All I want is for my package to support older Python versions. What should I do when at the same time I need numpy?

EDIT:

I got it working with environment markers. AFAIK this can't be done directly with the CLI, but requires putting something like

python = "^3.6"
numpy = [    
    {version = "*", python = "^3.8"},
    {version = "~1.21.6", python = "=3.7"},
    {version = "~1.19.5", python = "=3.6"}
]

into pyproject.toml. The version numbers above are what I obtained from doing pip install numpy inside venvs with cpy36, 37 and 39 (Windows 10). With this, poetry will always succeed installing numpy, no matter the python version in the venv.

@clintonroy
Copy link
Contributor

I just came here looking to suggest markers to you. Poetry does not resolve for the current environment, it resolves for all constraints in the configuration.

@J3ronimo
Copy link

@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.

@thedomdom
Copy link

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

This also solved the issue for me. Thanks @acviana

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/question User questions (candidates for conversion to discussion)
Projects
None yet
Development

No branches or pull requests