Pip3 install rasa does not work because of incompatibility between Cython 3.0 and PyYaml 5.x

The following cmd

pip3 install rasa

errors out because of incompatibility between Cython 3.0 and PyYaml 5.x.

Here’s a log of the error

❯ pip3 install rasa                                                          ─╯
Collecting rasa
  Downloading rasa-3.6.2-py3-none-any.whl (835 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 835.5/835.5 kB 4.9 MB/s eta 0:00:00
Collecting CacheControl<0.13.0,>=0.12.9 (from rasa)
  Downloading CacheControl-0.12.14-py2.py3-none-any.whl (21 kB)
Collecting PyJWT[crypto]<3.0.0,>=2.0.0 (from rasa)
  Downloading PyJWT-2.8.0-py3-none-any.whl (22 kB)
Collecting SQLAlchemy<1.5.0,>=1.4.0 (from rasa)
  Downloading SQLAlchemy-1.4.49.tar.gz (8.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.5/8.5 MB 26.3 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting absl-py<1.5,>=0.9 (from rasa)
  Downloading absl_py-1.4.0-py3-none-any.whl (126 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 126.5/126.5 kB 16.1 MB/s eta 0:00:00
Collecting aio-pika<8.2.4,>=6.7.1 (from rasa)
  Downloading aio_pika-8.2.3-py3-none-any.whl (49 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.0/50.0 kB 7.4 MB/s eta 0:00:00
Collecting aiogram<2.26 (from rasa)
  Downloading aiogram-2.25.1-py3-none-any.whl (203 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 203.4/203.4 kB 19.9 MB/s eta 0:00:00
Collecting aiohttp!=3.7.4.post0,<3.9,>=3.6 (from rasa)
  Downloading aiohttp-3.8.4-cp39-cp39-macosx_11_0_arm64.whl (338 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 338.3/338.3 kB 31.9 MB/s eta 0:00:00
Collecting apscheduler<3.10,>=3.6 (from rasa)
  Downloading APScheduler-3.9.1.post1-py2.py3-none-any.whl (59 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.6/59.6 kB 9.3 MB/s eta 0:00:00
Collecting attrs<22.2,>=19.3 (from rasa)
  Downloading attrs-22.1.0-py2.py3-none-any.whl (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.8/58.8 kB 7.9 MB/s eta 0:00:00
Collecting boto3<2.0.0,>=1.26.136 (from rasa)
  Downloading boto3-1.28.5-py3-none-any.whl (135 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 135.7/135.7 kB 23.0 MB/s eta 0:00:00
Collecting cloudpickle<2.3,>=1.2 (from rasa)
  Downloading cloudpickle-2.2.1-py3-none-any.whl (25 kB)
Collecting colorclass<2.3,>=2.2 (from rasa)
  Downloading colorclass-2.2.2-py2.py3-none-any.whl (18 kB)
Collecting coloredlogs<16,>=10 (from rasa)
  Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.0/46.0 kB 5.7 MB/s eta 0:00:00
Collecting colorhash<1.3.0,>=1.0.2 (from rasa)
  Downloading colorhash-1.2.1-py3-none-any.whl (5.7 kB)
Collecting confluent-kafka<3.0.0,>=1.9.2 (from rasa)
  Downloading confluent_kafka-2.2.0-cp39-cp39-macosx_11_0_arm64.whl (2.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.8/2.8 MB 41.5 MB/s eta 0:00:00
Collecting dask==2022.10.2 (from rasa)
  Downloading dask-2022.10.2-py3-none-any.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 38.3 MB/s eta 0:00:00
Collecting fbmessenger<6.1.0,>=6.0.0 (from rasa)
  Downloading fbmessenger-6.0.0-py2.py3-none-any.whl (11 kB)
Collecting google-auth<3 (from rasa)
  Downloading google_auth-2.22.0-py2.py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.8/181.8 kB 23.2 MB/s eta 0:00:00
Collecting joblib<1.3.0,>=0.15.1 (from rasa)
  Downloading joblib-1.2.0-py3-none-any.whl (297 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 298.0/298.0 kB 29.1 MB/s eta 0:00:00
Collecting jsonpickle<3.1,>=1.3 (from rasa)
  Downloading jsonpickle-3.0.1-py2.py3-none-any.whl (40 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.5/40.5 kB 4.9 MB/s eta 0:00:00
Collecting jsonschema<4.18,>=3.2 (from rasa)
  Downloading jsonschema-4.17.3-py3-none-any.whl (90 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.4/90.4 kB 11.6 MB/s eta 0:00:00
Collecting matplotlib<3.6,>=3.1 (from rasa)
  Downloading matplotlib-3.5.3-cp39-cp39-macosx_11_0_arm64.whl (7.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.2/7.2 MB 26.9 MB/s eta 0:00:00
Collecting mattermostwrapper<2.3,>=2.2 (from rasa)
  Downloading mattermostwrapper-2.2.tar.gz (2.5 kB)
  Preparing metadata (setup.py) ... done
Collecting networkx<2.7,>=2.4 (from rasa)
  Downloading networkx-2.6.3-py3-none-any.whl (1.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 30.3 MB/s eta 0:00:00
Collecting numpy<1.25.0,>=1.19.2 (from rasa)
  Downloading numpy-1.24.4-cp39-cp39-macosx_11_0_arm64.whl (13.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.9/13.9 MB 25.5 MB/s eta 0:00:00
Collecting packaging<21.0,>=20.0 (from rasa)
  Downloading packaging-20.9-py2.py3-none-any.whl (40 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.9/40.9 kB 4.6 MB/s eta 0:00:00
Collecting pluggy<2.0.0,>=1.0.0 (from rasa)
  Downloading pluggy-1.2.0-py3-none-any.whl (17 kB)
Collecting portalocker<3.0.0,>=2.7.0 (from rasa)
  Downloading portalocker-2.7.0-py2.py3-none-any.whl (15 kB)
Collecting prompt-toolkit<3.0.29,>=3.0 (from rasa)
  Downloading prompt_toolkit-3.0.28-py3-none-any.whl (380 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 380.2/380.2 kB 31.4 MB/s eta 0:00:00
Collecting protobuf<4.23.4,>=4.23.3 (from rasa)
  Downloading protobuf-4.23.3-cp37-abi3-macosx_10_9_universal2.whl (400 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 400.3/400.3 kB 31.3 MB/s eta 0:00:00
Collecting psycopg2-binary<2.10.0,>=2.8.2 (from rasa)
  Downloading psycopg2_binary-2.9.6-cp39-cp39-macosx_11_0_arm64.whl (2.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 20.9 MB/s eta 0:00:00
Collecting pydantic<1.10.10 (from rasa)
  Downloading pydantic-1.10.9-cp39-cp39-macosx_11_0_arm64.whl (2.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.6/2.6 MB 35.1 MB/s eta 0:00:00
Collecting pydot<1.5,>=1.4 (from rasa)
  Downloading pydot-1.4.2-py2.py3-none-any.whl (21 kB)
Collecting pykwalify<1.9,>=1.7 (from rasa)
  Downloading pykwalify-1.8.0-py2.py3-none-any.whl (24 kB)
Collecting pymongo[srv,tls]<4.4,>=3.8 (from rasa)
  Downloading pymongo-4.3.3-cp39-cp39-macosx_10_9_universal2.whl (413 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 413.2/413.2 kB 30.4 MB/s eta 0:00:00
Collecting python-dateutil<2.9,>=2.8 (from rasa)
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 17.3 MB/s eta 0:00:00
Collecting python-engineio!=5.0.0,<6,>=4 (from rasa)
  Downloading python_engineio-4.5.1-py3-none-any.whl (53 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.5/53.5 kB 6.7 MB/s eta 0:00:00
Collecting python-socketio<6,>=4.4 (from rasa)
  Downloading python_socketio-5.8.0-py3-none-any.whl (56 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.0/57.0 kB 7.1 MB/s eta 0:00:00
Collecting pytz<2023.0,>=2019.1 (from rasa)
  Downloading pytz-2022.7.1-py2.py3-none-any.whl (499 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 499.4/499.4 kB 33.8 MB/s eta 0:00:00
Collecting pyyaml<6.0,>=5.3.1 (from rasa)
  Downloading PyYAML-5.4.1.tar.gz (175 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.1/175.1 kB 18.8 MB/s eta 0:00:00
  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
  ╰─> [62 lines of output]
      /private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
      !!

              ********************************************************************************
              The license_file parameter is deprecated, use license_files instead.

              By 2023-Oct-30, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************

      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      running egg_info
      writing lib3/PyYAML.egg-info/PKG-INFO
      writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
      writing top-level names to lib3/PyYAML.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/Users/nitin/miniconda3/envs/llm/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/nitin/miniconda3/envs/llm/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 "/Users/nitin/miniconda3/envs/llm/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 "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/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/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 271, in <module>
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
          super().run_command(command)
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 314, in run
          self.find_sources()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 322, in find_sources
          mm.run()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 551, in run
          self.add_defaults()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults
          sdist.add_defaults(self)
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/command/sdist.py", line 104, in add_defaults
          super().add_defaults()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
          self._add_defaults_ext()
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
        File "<string>", line 201, in get_source_files
        File "/private/var/folders/vm/19fnf0v1739c6_w81mw624l00000gq/T/pip-build-env-cz9l59nj/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [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.

This is because rasa requires pyyaml<6.0,>=5.3.1 and Cython 3.0 has also been released (2023-07-17). This issue is being tracked here pyyaml issues

The way to fix this is to run the following cmd in your venv

pip install "Cython<3.0" "pyyaml<6" --no-build-isolation
pip3 install rasa

The real solution here seems to be to bump the required version from pyyaml<6.0,>5.3.1 to pyyaml>=6.0 in the requirements for rasa

Install the PyYAML 5.3.1 and then run pip install rasa. That works currently solving the PyYAML-5.4.1.tar.gz error until they update at Rasa.

Just run: pip install PyYAML==5.3.1 pip install rasa