An Unofficial Guide to Installing Rasa on an M1 Macbook

How do we install transformers in mac M1?

Hi I am facing issues with the pyscopg2-binary package when installing the dependencies in the conda environment

Collecting psycopg2-binary==2.9.3
  Using cached psycopg2-binary-2.9.3.tar.gz (380 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      running egg_info
      creating /private/var/folders/h4/j57570j90r50ttzbhysb342c0000gn/T/pip-pip-egg-info-blx_uvo9/psycopg2_binary.egg-info
      writing /private/var/folders/h4/j57570j90r50ttzbhysb342c0000gn/T/pip-pip-egg-info-blx_uvo9/psycopg2_binary.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/h4/j57570j90r50ttzbhysb342c0000gn/T/pip-pip-egg-info-blx_uvo9/psycopg2_binary.egg-info/dependency_links.txt
      writing top-level names to /private/var/folders/h4/j57570j90r50ttzbhysb342c0000gn/T/pip-pip-egg-info-blx_uvo9/psycopg2_binary.egg-info/top_level.txt
      writing manifest file '/private/var/folders/h4/j57570j90r50ttzbhysb342c0000gn/T/pip-pip-egg-info-blx_uvo9/psycopg2_binary.egg-info/SOURCES.txt'
      
      Error: pg_config executable not found.
      
      pg_config is required to build psycopg2 from source.  Please add the directory
      containing pg_config to the $PATH or specify the full executable path with the
      option:
      
          python setup.py build_ext --pg-config /path/to/pg_config build ...
      
      or with the pg_config option in 'setup.cfg'.
      
      If you prefer to avoid building psycopg2 from source, please install the PyPI
      'psycopg2-binary' package instead.
      
      For further information please check the 'doc/src/install.rst' file (also at
      <https://www.psycopg.org/docs/install.html>).
      
      [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

Hi! Sorry for the later response

I made some changes because incompatibility problems with rasa 2.8 I’m sharing my env file. You can download and fallow these steps:

Steps:

conda env create -v --name rasa2-8 -f env_rasa2-8.yml
pip install git+https://github.com/vpol/text.git --no-deps
pip install git+https://github.com/RasaHQ/rasa-sdk@2.8.0 --no-deps
pip install git+https://github.com/RasaHQ/rasa@2.8.27 --no-deps

rasa --version

env_rasa2-8.yml (4.0 KB)

1 Like

hi @itsjhonny !

I successfully installed Rasa on my M1 based on your guide, following up from this thread. Thank you! However, I am running into this when I run rasa train over on terminal:

I am not able to interact with the bot after running rasa shell in the terminal. What am I doing wrong?

Metal device set to: Apple M1

systemMemory: 8.00 GB
maxCacheSize: 2.67 GB

/opt/homebrew/Caskroom/miniforge/base/envs/rasadev/lib/python3.8/site-packages/rasa/utils/tensorflow/model_data.py:750: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  np.concatenate(np.array(f)),
Epochs: 100%|███████| 100/100 [00:22<00:00,  4.47it/s, t_loss=1.27, i_acc=0.986]
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Finished training component.
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Starting to train component EntitySynonymMapper
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Finished training component.
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Starting to train component ResponseSelector
2022-07-21 11:40:13 INFO     rasa.nlu.selectors.response_selector  - Retrieval intent parameter was left to its default value. This response selector will be trained on training examples combining all retrieval intents.
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Finished training component.
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Starting to train component FallbackClassifier
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Finished training component.
2022-07-21 11:40:13 INFO     rasa.nlu.model  - Successfully saved model into '/var/folders/rt/4dsv7dh93zbdjyj0hzvg12r00000gn/T/tmp525_f13q/nlu'
NLU model training completed.
Training Core model...
2022-07-21 11:40:20 WARNING  rasa.utils.common  - Failed to write global config. Error: [Errno 13] Permission denied: '/Users/karan/.config/rasa'. Skipping.
2022-07-21 11:40:20 WARNING  rasa.shared.utils.common  - The UnexpecTED Intent Policy is currently experimental and might change or be removed in the future 🔬 Please share your feedback on it in the forum (http://forum.rasa.com) to help us make this feature ready for production.
Processed story blocks: 100%|█████| 3/3 [00:00<00:00, 3355.44it/s, # trackers=1]
Processed story blocks: 100%|█████| 3/3 [00:00<00:00, 1581.17it/s, # trackers=3]
Processed story blocks: 100%|█████| 3/3 [00:00<00:00, 381.44it/s, # trackers=12]
Processed story blocks: 100%|██████| 3/3 [00:00<00:00, 93.69it/s, # trackers=39]
Processed rules: 100%|████████████| 2/2 [00:00<00:00, 5679.49it/s, # trackers=1]
Processed trackers: 100%|██████████| 3/3 [00:00<00:00, 3057.82it/s, # action=12]
Processed actions: 12it [00:00, 15582.55it/s, # examples=12]
Processed trackers: 100%|███████████| 2/2 [00:00<00:00, 5302.53it/s, # action=5]
Processed actions: 5it [00:00, 31823.25it/s, # examples=4]
Processed trackers: 100%|██████████| 3/3 [00:00<00:00, 3192.01it/s, # action=12]
Processed trackers: 100%|███████████████████████| 2/2 [00:00<00:00, 3502.55it/s]
Processed trackers: 100%|███████████████████████| 5/5 [00:00<00:00, 2430.64it/s]
Processed trackers: 100%|██████| 120/120 [00:00<00:00, 5289.16it/s, # intent=12]
/opt/homebrew/Caskroom/miniforge/base/envs/rasadev/lib/python3.8/site-packages/rasa/utils/tensorflow/model_data_utils.py:383: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  np.array(values), number_of_dimensions=4
Epochs:   0%|                                           | 0/100 [00:00<?, ?it/s]/opt/homebrew/Caskroom/miniforge/base/envs/rasadev/lib/python3.8/site-packages/tensorflow/python/framework/indexed_slices.py:448: UserWarning: Converting sparse IndexedSlices(IndexedSlices(indices=Tensor("gradients/cond_grad/Identity_1:0", shape=(None,), dtype=int64), values=Tensor("gradients/cond_grad/Identity:0", shape=(None,), dtype=float32), dense_shape=Tensor("gradients/cond_grad/Identity_2:0", shape=(1,), dtype=int32))) to a dense Tensor of unknown shape. This may consume a large amount of memory.
  warnings.warn(
/opt/homebrew/Caskroom/miniforge/base/envs/rasadev/lib/python3.8/site-packages/tensorflow/python/framework/indexed_slices.py:448: UserWarning: Converting sparse IndexedSlices(IndexedSlices(indices=Tensor("gradients/cond_1_grad/Identity_1:0", shape=(None,), dtype=int64), values=Tensor("gradients/cond_1_grad/Identity:0", shape=(None,), dtype=float32), dense_shape=Tensor("gradients/cond_1_grad/Identity_2:0", shape=(1,), dtype=int32))) to a dense Tensor of unknown shape. This may consume a large amount of memory.
  warnings.warn(
2022-07-21 11:40:28.403487: F tensorflow/core/framework/tensor.cc:681] Check failed: IsAligned() ptr = 0x2bea09910
zsh: abort      rasa train
(rasadev) karan@Nishakarans-MacBook-Air development % /opt/homebrew/Caskroom/miniforge/base/envs/rasadev/lib/python3.8/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d ''```

running rasa shell results in this

How can I install spacy models?

I could use the miniforge env above to install spacy 3.2.2, it seems there’s no issue. But the issue is now on actually training and running rasa for me :upside_down_face:

I think this is due to resource problem? Maybe you can try with a smaller training set.

Shouldn’t

conda activate rasa2-8

be called before calling the pip install ... commands?

Is there a way to install Rasa X? Or is that still a no for the M1 chip.

Created a repo with a step-by-step quickstart document here (for rasa 2.8.27)

1 Like
ERROR: Failed building wheel for xmlsec
ERROR: Could not build wheels for xmlsec, which is required to install pyproject.toml-based projects

failed
Traceback (most recent call last):
  File "/Users/faridzuan/miniforge3/lib/python3.10/site-packages/conda/exceptions.py", line 1129, in __call__
    return func(*args, **kwargs)
  File "/Users/faridzuan/miniforge3/lib/python3.10/site-packages/conda_env/cli/main.py", line 80, in do_call
    exit_code = getattr(module, func_name)(args, parser)
  File "/Users/faridzuan/miniforge3/lib/python3.10/site-packages/conda/notices/core.py", line 72, in wrapper
    return_value = func(*args, **kwargs)
  File "/Users/faridzuan/miniforge3/lib/python3.10/site-packages/conda_env/cli/main_create.py", line 156, in execute
    result[installer_type] = installer.install(prefix, pkg_specs, args, env)
  File "/Users/faridzuan/miniforge3/lib/python3.10/site-packages/conda_env/installers/pip.py", line 70, in install
    return _pip_install_via_requirements(*args, **kwargs)
  File "/Users/faridzuan/miniforge3/lib/python3.10/site-packages/conda_env/installers/pip.py", line 53, in _pip_install_via_requirements
    stdout, stderr = pip_subprocess(pip_cmd, prefix, cwd=pip_workdir)
  File "/Users/faridzuan/miniforge3/lib/python3.10/site-packages/conda_env/pip_util.py", line 41, in pip_subprocess
    raise CondaEnvException("Pip failed")
conda.exceptions.CondaEnvException: Pip failed

This is the error im facing during conda enviroment creation

Hi @WTFFARIDZ, please take a look at Rasa Open Source 3.3 launched

1 Like

Thank you sharing it here.

Does anyone have ways to install Rasa Open Source 3.2X on M1 ?

I can install with pip3 install rasa. But as soon as I try to do rasa init, it gets stuck at the training step. I am on M1 Macbook Pro 14" with Ventura 13.0.1. Pls help, I need rasa for my thesis. I already tried the top post.

1 Like

Rasa now supports M1 macbooks Hello Rasa Community!

I’m excited to announce that Rasa Open Source 3.3 has been released, and the docs have been updated. This launch includes a major improvement: Rasa supports native installations on Apple Silicon (M1/M2).

This also includes other updates like, continuous event export , caching message along with some bug fixes. You can find the full release notes here

Could not find a version that satisfies the requirement tensorflow<2.7.0,>=2.6.2 (from rasa) (from versions: none)

I am unable to install the rasa version 2.8.15 on my MacBook Air with M1 chip.

When I tried to install the rasa version 2.8.15 in macOS(Ventura 13.0) in PyCharm with a virtual environment having Python3.8 using the command

python3 -m pip install rasa==2.8.15

This is the error that it is raising related to tensorflow

ERROR: Could not find a version that satisfies the requirement tensorflow<2.7.0,>=2.6.2 (from rasa) (from versions: none)

ERROR: No matching distribution found for tensorflow<2.7.0,>=2.6.2

And while trying to install the tensorflow version 2.7.0 using the command

python3 -m pip install tensorflow==2.7.0

It is raising below error

ERROR: Could not find a version that satisfies the requirement tensorflow==2.7.0 (from versions: none)

ERROR: No matching distribution found for tensorflow==2.7.0

I googled the error and tried some of the things which were suggested to other people, but nothing worked for me.

Please suggest me a way, how can I install tensorflow version 2.7.0 on my MacBook Air M1.

So I can install rasa.

Thanks.

ERROR: Package 'rasa' requires a different Python: 3.9.6 not in '<3.9,>=3.7'

Got this error while installing it ``` pip install git+https://github.com/RasaHQ/rasa.git@3.0.4 --no-deps

I wasn’t able to use this approach but managed to install Rasa using python 3.9.12 and uninstalling and re-installing pip. Made a small guide here: Install Rasa in MacOS with M1 or M2 | by Gonzalo Mordecki | Feb, 2023 | Medium