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

Getting requirements to build wheel ... error >>> Error compiling Cython file: spacy/vocab.pxd:28:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead. #16

Open
maprann opened this issue Jul 31, 2023 · 4 comments

Comments

@maprann
Copy link

maprann commented Jul 31, 2023

pip3 install cso.classifier
Collecting cso.classifier
Obtaining dependency information for cso.classifier from https://files.pythonhosted.org/packages/e3/77/85c910382095e77bf6a431b3e3d9fb588c4db6d2f455c18dfd9dc620dbaf/cso_classifier-3.1-py3-none-any.whl.metadata
Using cached cso_classifier-3.1-py3-none-any.whl.metadata (43 kB)
Collecting gensim==3.8.3 (from cso.classifier)
Using cached gensim-3.8.3.tar.gz (23.4 MB)
Preparing metadata (setup.py) ... done
Collecting click==7.1.2 (from cso.classifier)
Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting hurry.filesize==0.9 (from cso.classifier)
Using cached hurry.filesize-0.9.tar.gz (2.8 kB)
Preparing metadata (setup.py) ... done
Collecting kneed==0.3.1 (from cso.classifier)
Using cached kneed-0.3.1.tar.gz (9.1 kB)
Preparing metadata (setup.py) ... done
Collecting nltk==3.6.2 (from cso.classifier)
Using cached nltk-3.6.2-py3-none-any.whl (1.5 MB)
Collecting rapidfuzz==2.11.1 (from cso.classifier)
Using cached rapidfuzz-2.11.1-cp38-cp38-macosx_11_0_arm64.whl (1.1 MB)
Requirement already satisfied: numpy>=1.19.5 in ./outdovenv/lib/python3.8/site-packages (from cso.classifier) (1.24.4)
Collecting requests==2.25.1 (from cso.classifier)
Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting spacy==3.0.5 (from cso.classifier)
Using cached spacy-3.0.5.tar.gz (7.0 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [164 lines of output]

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      int length
  
  
  cdef class Vocab:
      cdef Pool mem
      cpdef readonly StringStore strings
            ^
  ------------------------------------------------------------
  
  spacy/vocab.pxd:28:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  
  
  cdef class Vocab:
      cdef Pool mem
      cpdef readonly StringStore strings
      cpdef public Morphology morphology
            ^
  ------------------------------------------------------------
  
  spacy/vocab.pxd:29:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  
  cdef class Vocab:
      cdef Pool mem
      cpdef readonly StringStore strings
      cpdef public Morphology morphology
      cpdef public object vectors
            ^
  ------------------------------------------------------------
  
  spacy/vocab.pxd:30:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  cdef class Vocab:
      cdef Pool mem
      cpdef readonly StringStore strings
      cpdef public Morphology morphology
      cpdef public object vectors
      cpdef public object _lookups
            ^
  ------------------------------------------------------------
  
  spacy/vocab.pxd:31:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      cdef Pool mem
      cpdef readonly StringStore strings
      cpdef public Morphology morphology
      cpdef public object vectors
      cpdef public object _lookups
      cpdef public object writing_system
            ^
  ------------------------------------------------------------
  
  spacy/vocab.pxd:32:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      cpdef readonly StringStore strings
      cpdef public Morphology morphology
      cpdef public object vectors
      cpdef public object _lookups
      cpdef public object writing_system
      cpdef public object get_noun_chunks
            ^
  ------------------------------------------------------------
  
  spacy/vocab.pxd:33:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
  
  Error compiling Cython file:
  ------------------------------------------------------------
  ...
      cdef float prior_prob
  
  
  cdef class KnowledgeBase:
      cdef Pool mem
      cpdef readonly Vocab vocab
            ^
  ------------------------------------------------------------
  
  spacy/kb.pxd:31:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
  Copied /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-tahcqqn5/spacy_ddb6de360bea4cdc9ba96d5305d51c66/setup.cfg -> /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-tahcqqn5/spacy_ddb6de360bea4cdc9ba96d5305d51c66/spacy/tests/package
  Copied /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-tahcqqn5/spacy_ddb6de360bea4cdc9ba96d5305d51c66/pyproject.toml -> /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-tahcqqn5/spacy_ddb6de360bea4cdc9ba96d5305d51c66/spacy/tests/package
  Cythonizing sources
  Compiling spacy/training/example.pyx because it changed.
  Compiling spacy/parts_of_speech.pyx because it changed.
  Compiling spacy/strings.pyx because it changed.
  Compiling spacy/lexeme.pyx because it changed.
  Compiling spacy/vocab.pyx because it changed.
  Compiling spacy/attrs.pyx because it changed.
  Compiling spacy/kb.pyx because it changed.
  Compiling spacy/ml/parser_model.pyx because it changed.
  Compiling spacy/morphology.pyx because it changed.
  Compiling spacy/pipeline/dep_parser.pyx because it changed.
  Compiling spacy/pipeline/morphologizer.pyx because it changed.
  Compiling spacy/pipeline/multitask.pyx because it changed.
  Compiling spacy/pipeline/ner.pyx because it changed.
  Compiling spacy/pipeline/pipe.pyx because it changed.
  Compiling spacy/pipeline/trainable_pipe.pyx because it changed.
  Compiling spacy/pipeline/sentencizer.pyx because it changed.
  Compiling spacy/pipeline/senter.pyx because it changed.
  Compiling spacy/pipeline/tagger.pyx because it changed.
  Compiling spacy/pipeline/transition_parser.pyx because it changed.
  Compiling spacy/pipeline/_parser_internals/arc_eager.pyx because it changed.
  Compiling spacy/pipeline/_parser_internals/ner.pyx because it changed.
  Compiling spacy/pipeline/_parser_internals/nonproj.pyx because it changed.
  Compiling spacy/pipeline/_parser_internals/_state.pyx because it changed.
  Compiling spacy/pipeline/_parser_internals/stateclass.pyx because it changed.
  Compiling spacy/pipeline/_parser_internals/transition_system.pyx because it changed.
  Compiling spacy/pipeline/_parser_internals/_beam_utils.pyx because it changed.
  Compiling spacy/tokenizer.pyx because it changed.
  Compiling spacy/training/align.pyx because it changed.
  Compiling spacy/training/gold_io.pyx because it changed.
  Compiling spacy/tokens/doc.pyx because it changed.
  Compiling spacy/tokens/span.pyx because it changed.
  Compiling spacy/tokens/token.pyx because it changed.
  Compiling spacy/tokens/span_group.pyx because it changed.
  Compiling spacy/tokens/graph.pyx because it changed.
  Compiling spacy/tokens/morphanalysis.pyx because it changed.
  Compiling spacy/tokens/_retokenize.pyx because it changed.
  Compiling spacy/matcher/matcher.pyx because it changed.
  Compiling spacy/matcher/phrasematcher.pyx because it changed.
  Compiling spacy/matcher/dependencymatcher.pyx because it changed.
  Compiling spacy/symbols.pyx because it changed.
  Compiling spacy/vectors.pyx because it changed.
  [ 1/41] Cythonizing spacy/attrs.pyx
  [ 2/41] Cythonizing spacy/kb.pyx
  Traceback (most recent call last):
    File "/Users/maisonsirginou/Documents/outdo/codeOutdo/outdovenv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/Users/maisonsirginou/Documents/outdo/codeOutdo/outdovenv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/maisonsirginou/Documents/outdo/codeOutdo/outdovenv/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-utncu2_x/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-utncu2_x/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-utncu2_x/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 224, in <module>
    File "<string>", line 211, in setup_package
    File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-utncu2_x/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
      cythonize_one(*args)
    File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-utncu2_x/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: spacy/kb.pyx
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I am using python 3.8.17 in a venv, MacOS
Cython version is 0.29.28
I have another spacy installed in the venv version 3.6.0

I tried pip install pip setuptools wheel Cython==0.29.28....
Same issue.

Thank you for your time and comments on how this can be solved

@angelosalatino
Copy link
Owner

Hi,

Have you tried to use python 3.7? or on a brand new environment?

I am sorry, but this is a new issue that I have never encountered before.

@maprann
Copy link
Author

maprann commented Jul 31, 2023

Hi Angelo. Thank you for the quick reply. I will try and come back to you.
In the meantime I discovered this: https://cython.readthedocs.io/en/latest/src/changes.html
in the "related changes:" section :
Variables can no longer be declared with cpdef. Patch by David Woods. (Github issue #887)

@maprann
Copy link
Author

maprann commented Jul 31, 2023

Hello @angelosalatino - I tried with python 3.7.17 on Mac, VSCode, ZSh, and a new venv -- I have the same error.
Cython.Compiler.Errors.CompileError: spacy/kb.pyx

❯ python -m venv outdovenv
❯ source outdovenv/bin/activate
❯ pip list
Package Version
pip 23.0.1
setuptools 47.1.0
❯ pyenv version
3.7.17 (set by /Users/maisonsirginou/.pyenv/version)
❯ pyenv versions
system
3.6.15
==> 3.7.17 (set by /Users/maisonsirginou/.pyenv/version)
3.8.17
3.9.17
......
====> Error below <====

 > pip install cso-classifier
Collecting cso-classifier
  Obtaining dependency information for cso-classifier from https://files.pythonhosted.org/packages/e3/77/85c910382095e77bf6a431b3e3d9fb588c4db6d2f455c18dfd9dc620dbaf/cso_classifier-3.1-py3-none-any.whl.metadata
  Using cached cso_classifier-3.1-py3-none-any.whl.metadata (43 kB)
Collecting gensim==3.8.3 (from cso-classifier)
  Using cached gensim-3.8.3.tar.gz (23.4 MB)
  Preparing metadata (setup.py) ... done
Collecting click==7.1.2 (from cso-classifier)
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting hurry.filesize==0.9 (from cso-classifier)
  Using cached hurry.filesize-0.9.tar.gz (2.8 kB)
  Preparing metadata (setup.py) ... done
Collecting kneed==0.3.1 (from cso-classifier)
  Using cached kneed-0.3.1.tar.gz (9.1 kB)
  Preparing metadata (setup.py) ... done
Collecting nltk==3.6.2 (from cso-classifier)
  Using cached nltk-3.6.2-py3-none-any.whl (1.5 MB)
Collecting rapidfuzz==2.11.1 (from cso-classifier)
  Using cached rapidfuzz-2.11.1.tar.gz (813 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.19.5 in /Users/maisonsirginou/.pyenv/versions/3.7.17/lib/python3.7/site-packages (from cso-classifier) (1.21.6)
Collecting requests==2.25.1 (from cso-classifier)
  Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting spacy==3.0.5 (from cso-classifier)
  Using cached spacy-3.0.5.tar.gz (7.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [164 lines of output]
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          int length
      
      
      cdef class Vocab:
          cdef Pool mem
          cpdef readonly StringStore strings
                ^
      ------------------------------------------------------------
      
      spacy/vocab.pxd:28:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      
      cdef class Vocab:
          cdef Pool mem
          cpdef readonly StringStore strings
          cpdef public Morphology morphology
                ^
      ------------------------------------------------------------
      
      spacy/vocab.pxd:29:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      cdef class Vocab:
          cdef Pool mem
          cpdef readonly StringStore strings
          cpdef public Morphology morphology
          cpdef public object vectors
                ^
      ------------------------------------------------------------
      
      spacy/vocab.pxd:30:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      cdef class Vocab:
          cdef Pool mem
          cpdef readonly StringStore strings
          cpdef public Morphology morphology
          cpdef public object vectors
          cpdef public object _lookups
                ^
      ------------------------------------------------------------
      
      spacy/vocab.pxd:31:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cdef Pool mem
          cpdef readonly StringStore strings
          cpdef public Morphology morphology
          cpdef public object vectors
          cpdef public object _lookups
          cpdef public object writing_system
                ^
      ------------------------------------------------------------
      
      spacy/vocab.pxd:32:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cpdef readonly StringStore strings
          cpdef public Morphology morphology
          cpdef public object vectors
          cpdef public object _lookups
          cpdef public object writing_system
          cpdef public object get_noun_chunks
                ^
      ------------------------------------------------------------
      
      spacy/vocab.pxd:33:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cdef float prior_prob
      
      
      cdef class KnowledgeBase:
          cdef Pool mem
          cpdef readonly Vocab vocab
                ^
      ------------------------------------------------------------
      
      spacy/kb.pxd:31:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
      Copied /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-w8m46vaf/spacy_249ac8ccd62f47038ca166d14738d25e/setup.cfg -> /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-w8m46vaf/spacy_249ac8ccd62f47038ca166d14738d25e/spacy/tests/package
      Copied /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-w8m46vaf/spacy_249ac8ccd62f47038ca166d14738d25e/pyproject.toml -> /private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-install-w8m46vaf/spacy_249ac8ccd62f47038ca166d14738d25e/spacy/tests/package
      Cythonizing sources
      Compiling spacy/training/example.pyx because it changed.
      Compiling spacy/parts_of_speech.pyx because it changed.
      Compiling spacy/strings.pyx because it changed.
      Compiling spacy/lexeme.pyx because it changed.
      Compiling spacy/vocab.pyx because it changed.
      Compiling spacy/attrs.pyx because it changed.
      Compiling spacy/kb.pyx because it changed.
      Compiling spacy/ml/parser_model.pyx because it changed.
      Compiling spacy/morphology.pyx because it changed.
      Compiling spacy/pipeline/dep_parser.pyx because it changed.
      Compiling spacy/pipeline/morphologizer.pyx because it changed.
      Compiling spacy/pipeline/multitask.pyx because it changed.
      Compiling spacy/pipeline/ner.pyx because it changed.
      Compiling spacy/pipeline/pipe.pyx because it changed.
      Compiling spacy/pipeline/trainable_pipe.pyx because it changed.
      Compiling spacy/pipeline/sentencizer.pyx because it changed.
      Compiling spacy/pipeline/senter.pyx because it changed.
      Compiling spacy/pipeline/tagger.pyx because it changed.
      Compiling spacy/pipeline/transition_parser.pyx because it changed.
      Compiling spacy/pipeline/_parser_internals/arc_eager.pyx because it changed.
      Compiling spacy/pipeline/_parser_internals/ner.pyx because it changed.
      Compiling spacy/pipeline/_parser_internals/nonproj.pyx because it changed.
      Compiling spacy/pipeline/_parser_internals/_state.pyx because it changed.
      Compiling spacy/pipeline/_parser_internals/stateclass.pyx because it changed.
      Compiling spacy/pipeline/_parser_internals/transition_system.pyx because it changed.
      Compiling spacy/pipeline/_parser_internals/_beam_utils.pyx because it changed.
      Compiling spacy/tokenizer.pyx because it changed.
      Compiling spacy/training/align.pyx because it changed.
      Compiling spacy/training/gold_io.pyx because it changed.
      Compiling spacy/tokens/doc.pyx because it changed.
      Compiling spacy/tokens/span.pyx because it changed.
      Compiling spacy/tokens/token.pyx because it changed.
      Compiling spacy/tokens/span_group.pyx because it changed.
      Compiling spacy/tokens/graph.pyx because it changed.
      Compiling spacy/tokens/morphanalysis.pyx because it changed.
      Compiling spacy/tokens/_retokenize.pyx because it changed.
      Compiling spacy/matcher/matcher.pyx because it changed.
      Compiling spacy/matcher/phrasematcher.pyx because it changed.
      Compiling spacy/matcher/dependencymatcher.pyx because it changed.
      Compiling spacy/symbols.pyx because it changed.
      Compiling spacy/vectors.pyx because it changed.
      [ 1/41] Cythonizing spacy/attrs.pyx
      [ 2/41] Cythonizing spacy/kb.pyx
      Traceback (most recent call last):
        File "/Users/maisonsirginou/.pyenv/versions/3.7.17/lib/python3.7/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/maisonsirginou/.pyenv/versions/3.7.17/lib/python3.7/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/maisonsirginou/.pyenv/versions/3.7.17/lib/python3.7/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-cevv5t7x/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-cevv5t7x/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-cevv5t7x/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 224, in <module>
        File "<string>", line 211, in setup_package
        File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-cevv5t7x/overlay/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
          cythonize_one(*args)
        File "/private/var/folders/xk/5rw7rdq566x_h9w02mgphnn80000gn/T/pip-build-env-cevv5t7x/overlay/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: spacy/kb.pyx
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

@guoziting112
Copy link

I have the same problem.
Cython.Compiler.Errors.CompileError: spacy/kb.pyx
[end of output]
I am using python =3.8.19 MacOS
@maprann Could you solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants