The Dan
The Dan

Reputation: 1690

Error Compiling `spacy` Package with Pip and Requirements.txt (Mac M1)

I'm trying to install the spacy package and its dependencies using pip and a requirements.txt file in a Python environment. However, I'm encountering the following error during the installation process:

requirements.txt

-i https://pypi.python.org/simple
anyio==3.7.0
appdirs==1.4.4
...
spacy==3.0.3
spacy-legacy==3.0.1
spacy-lookups-data==1.0.3
...
websockets==11.0.3
wrapt==1.15.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
xmltodict==0.13.0; python_version >= '3.4'
zipp==3.16.2; python_version >= '3.8'

I run the command pip install -r requirements.txt, also tried conda install --file requirements.txt

Error

      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 ".../lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File ".../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 ".../lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File ".../site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File ".../site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
          self.run_setup()
        File ".../site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 225, in <module>
        File "<string>", line 211, in setup_package
        File ".../site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File ".../site-packages/Cython/Build/Dependencies.py", line 1321, 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'm using Python 3.9.16 on macOS (M1). I've tried updating Pipenv, ensuring the correct dependencies are installed, and recreating the virtual environment, but I'm still encountering this issue. How can I resolve this error and successfully install the spacy package with its dependencies?

Upvotes: 0

Views: 1178

Answers (0)

Related Questions