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

BUG: pip install fail - Error compiling Cython #24377

Closed
Raoul555 opened this issue Aug 9, 2023 · 4 comments
Closed

BUG: pip install fail - Error compiling Cython #24377

Raoul555 opened this issue Aug 9, 2023 · 4 comments
Labels
32 - Installation Problems installing or compiling NumPy 50 - Duplicate

Comments

@Raoul555
Copy link

Raoul555 commented Aug 9, 2023

Describe the issue:

When trying to install numpy on my 22.04.2 LTS (Jammy Jellyfish) Unbutu laptop with pip, I'm getting a systematic compiling Cython error

Reproduce the code example:

$ python -m pip install numpy==1.18.5

Error message:

Collecting numpy==1.18.5
  Downloading numpy-1.18.5.zip (5.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.4/5.4 MB 22.4 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [56 lines of output]
      Running from numpy source directory.
      <string>:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      /tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/tools/cythonize.py:75: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        required_version = LooseVersion('0.29.14')
      /tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/tools/cythonize.py:77: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        if LooseVersion(cython_version) < required_version:
      warning: _philox.pyx:19:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
      warning: /tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/numpy/__init__.pxd:17:0: The 'DEF' statement is deprecated and will be removed in a future Cython version. Consider using global variables, constants, and in-place literals instead. See https://github.com/cython/cython/issues/4310
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  self.rng_state.ctr.v[i] = counter[i]
      
              self._reset_state_variables()
      
              self._bitgen.state = <void *>&self.rng_state
              self._bitgen.next_uint64 = &philox_uint64
                                         ^
      ------------------------------------------------------------
      
      _philox.pyx:195:35: Cannot assign type 'uint64_t (*)(void *) except? -1 nogil' to 'uint64_t (*)(void *) noexcept nogil'
      Processing numpy/random/_bounded_integers.pxd.in
      Processing numpy/random/_philox.pyx
      Traceback (most recent call last):
        File "/tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/tools/cythonize.py", line 238, in <module>
          main()
        File "/tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/tools/cythonize.py", line 234, in main
          find_process_files(root_dir)
        File "/tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/tools/cythonize.py", line 225, in find_process_files
          process(root_dir, fromfile, tofile, function, hash_db)
        File "/tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/tools/cythonize.py", line 191, in process
          processor_function(fromfile, tofile)
        File "/tmp/pip-install-0zxbecx9/numpy_01d616762b55471cb6f945696848574d/tools/cythonize.py", line 80, in process_pyx
          subprocess.check_call(
        File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/home/user/.cache/pypoetry/virtualenvs/mmsx-x4-NAZA1-py3.9/bin/python', '-m', 'cython', '-3', '--fast-fail', '-o', '_philox.c', '_philox.pyx']' returned non-zero exit status 1.
      Cythonizing sources
      Traceback (most recent call last):
        File "/home/user/.cache/pypoetry/virtualenvs/mmsx-x4-NAZA1-py3.9/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/user/.cache/pypoetry/virtualenvs/mmsx-x4-NAZA1-py3.9/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/user/.cache/pypoetry/virtualenvs/mmsx-x4-NAZA1-py3.9/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-ta9roshl/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 380, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/tmp/pip-build-env-ta9roshl/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-ta9roshl/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 488, in <module>
        File "<string>", line 469, in setup_package
        File "<string>", line 275, in generate_cython
      RuntimeError: Running cythonize failed!
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Runtime information:

>>> print(sys.version)
3.9.16 (main, Dec  7 2022, 01:12:08) 
[GCC 11.3.0]
$ python -m pip --version
pip 23.2.1 from /home/user/.cache/pypoetry/virtualenvs/foo-x4-NAZA1-py3.9/lib/python3.9/site-packages/pip (python 3.9)

Context for the issue:

I'm not able to install numpy

@mattip
Copy link
Member

mattip commented Aug 9, 2023

Duplicate of #24330. You will have to use a similar solution to make sure you use Cython<3.

As mentioned here you will have to use python -m pip install numpy==1.18.5 --no-build-isolation

@rgommers rgommers added 32 - Installation Problems installing or compiling NumPy and removed 00 - Bug labels Aug 11, 2023
@rgommers
Copy link
Member

I'll close this as a duplicate. Thanks for the report @Raoul555.

@ari62
Copy link

ari62 commented Apr 3, 2024

this worked for me (for the version of numpy i was targeting):

pip install Cython==0.29.37
pip install numpy==1.18.5 --no-build-isolation

@MoonRainy21
Copy link

this worked for me (for the version of numpy i was targeting):

pip install Cython==0.29.37
pip install numpy==1.18.5 --no-build-isolation

this also worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32 - Installation Problems installing or compiling NumPy 50 - Duplicate
Projects
None yet
Development

No branches or pull requests

5 participants