DEV Community

Cover image for How to Installing Rasa & Building Rasa Chatbot on an M1 Macbook.
Muhammad Mudassir
Muhammad Mudassir

Posted on • Edited on

How to Installing Rasa & Building Rasa Chatbot on an M1 Macbook.

First you setting up your environment setup.

1. Python Environment Setup:

you need to check your Python environment is already configured or not:

python3 --version
pip3 --version

If packages are already installed, these commands should display version numbers for each step, and you can skip to the next step.

Otherwise, going to install Here.

In MacOS:
Now you can install Python3.

brew update
brew install python

2. Virtual Environment Setup

This is the optional setup.but we strongly recommend isolating python projects using virtual environments. Tools like virtualenv and virtualenvwrapper provide isolated Python environments, which are cleaner than installing packages system-wide (as they prevent dependency conflicts). They also let you install packages without root privileges.

Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:

python3 -m venv ./venv

Activate the virtual environment:

source ./venv/bin/activate

If you want to Deactivate the Virtual enviroment:

deactivate

Now your venv enviroment setup is successfully ready.

But when you install Rasa in this enviroment in M1 MacOS you have getting error. so now we can resolve this issue by following this. a step-by-step guide that explains how I got Rasa to work on a M1 Macbook. These steps seem to work on MacOS Montery v12.0.1. If you use an ealier version of the operating system you’ll likely need to upgrade.it is likely that things might change depending on the Tensorflow support for these devices.

1. Installing system dependencies:

First, you’ll want to install some base dependencies for your operating system. We will use brew 27 for this. If you don’t have brew installed you can do so by running:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

The script explains what it will do and then pauses before it does it. Once brew is installed you can install the required system dependencies.

brew install libpq libxml2 libxmlsec1 pkg-config postgresql

2. Conda enviroment setup

we need to install conda to handle all our dependencies.You can install conda by running it locally in your terminal:

chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
source ~/miniforge3/bin/activate

This will activate an environment that is maintained by conda. That means that conda is able to handle our Tensorflow dependencies from here on. Conda does not work with requirements.txt files that you may be familiar with from pip. Instead we will use a env.yml file. Here’s the one that will use:

`channels:
  - apple
  - conda-forge

dependencies:
  - python==3.8.12
  - dask==2021.11.2
  - tensorflow-deps==2.6.0
  - numpy>=1.19.2,<1.20.0
  - scipy>=1.4.1,<1.8.0
  - scikit-learn>=0.22,<0.25
  - matplotlib==3.5.1
  - pip
  - pip:
      - absl-py==0.13.0
      - aio-pika==6.8.1
      - aiofiles==0.8.0
      - aioredis==2.0.1
      - aioresponses==0.7.2
      - aiormq==3.3.1
      - anyio==3.4.0
      - APScheduler==3.7.0
      - async-generator==1.10
      - async-timeout==4.0.2
      - aiohttp==3.8.1
      - httpcore==0.11.1
      - httplib2==0.20.2
      - httptools==0.3.0
      - httpx==0.15.4
      - bidict==0.21.4
      - blinker==1.4
      - boto3==1.20.28
      - botocore==1.23.28
      - CacheControl==0.12.10
      - cachy==0.3.0
      - certifi==2021.10.8
      - chardet==4.0.0
      - clang==5.0
      - cleo==0.8.1
      - clikit==0.6.2
      - colorama==0.4.4
      - colorclass==2.2.2
      - coloredlogs==15.0.1
      - colorhash==1.0.4
      - crashtest==0.3.1
      - croniter==1.1.0
      - cytoolz==0.11.2
      - decorator==5.1.0
      - defusedxml==0.7.1
      - distlib==0.3.4
      - dm-tree==0.1.6
      - docopt==0.6.2
      - fakeredis==1.7.0
      - fbmessenger==6.0.0
      - filelock==3.4.2
      - fire==0.4.0
      - flatbuffers==1.12
      - freezegun==1.1.0
      - future==0.18.2
      - gitdb==4.0.9
      - GitPython==3.1.3
      - google-auth==2.3.3
      - google-pasta==0.2.0
      - h11==0.9.0
      - HeapDict==1.0.1
      - html5lib==1.1
      - humanfriendly==10.0
      - isodate==0.6.1
      - jmespath==0.10.0
      - jsonpickle==2.0.0
      - jsonschema==3.2.0
      - kafka-python==2.0.2
      - keyring==21.8.0
      - locket==0.2.0
      - lockfile==0.12.2
      - lxml==4.7.1
      - mattermostwrapper==2.2
      - mock==4.0.3
      - multidict==5.0.0
      - munkres==1.1.4
      - mypy_extensions==0.4.3
      - networkx==2.6.3
      - oauth2client==4.1.3
      - onelogin==2.0.2
      - packaging==20.9
      - pamqp==2.3.0
      - pastel==0.2.1
      - pexpect==4.8.0
      - pika==1.2.0
      - pkgconfig==1.5.5
      - pkginfo==1.8.2
      - platformdirs==2.4.1
      - poetry==1.1.12
      - poetry-core==1.0.7
      - prompt-toolkit==2.0.10
      - protobuf==3.19.1
      - psycopg2-binary==2.9.3
      - ptyprocess==0.7.0
      - pyasn1==0.4.8
      - pyasn1-modules==0.2.7
      - pydot==1.4.2
      - pykwalify==1.8.0
      - pylev==1.4.0
      - pymongo==3.10.1
      - pyrsistent==0.18.0
      - pyTelegramBotAPI==3.8.3
      - python-crfsuite==0.9.7
      - python-engineio==4.3.0
      - python-socketio==5.5.0
      - python3-saml==1.12.0
      - questionary==1.10.0
      - randomname==0.1.5
      - redis==3.5.3
      - regex==2021.8.28
      - rfc3986==1.5.0
      - rocketchat-API==1.16.0
      - ruamel.yaml==0.16.13
      - ruamel.yaml.clib==0.2.2
      - s3transfer==0.5.0
      - sanic==21.6.0
      - sanic-jwt==1.7.0
      - sanic-plugin-toolkit==1.2.1
      - sanic-routing==0.7.0
      - sanic-cors==1.0.0
      - sentry-sdk==1.3.1
      - shellingham==1.4.0
      - simple-image-download==0.2
      - sklearn-crfsuite==0.3.6
      - slackclient==2.9.3
      - smmap==5.0.0
      - sniffio==1.2.0
      - SQLAlchemy==1.4.29
      - tabulate==0.8.9
      - tarsafe==0.0.3
      - tensorboard==2.7.0
      - tensorflow-estimator==2.6.0
      - tensorflow-hub==0.12.0
      - tensorflow-macos==2.6.0
      - tensorflow-metal==0.3.0
      - tensorflow-probability==0.13.0
      - termcolor==1.1.0
      - terminaltables==3.1.10
      - tfa-nightly==0.16.0.dev20220103155136
      - tomlkit==0.8.0
      - tqdm==4.62.3
      - twilio==6.50.1
      - typeguard==2.13.3
      - typing-utils==0.1.0
      - tzlocal==2.1
      - ujson==4.3.0
      - uvloop==0.14.0
      - virtualenv==20.13.0
      - wcwidth==0.2.5
      - webencodings==0.5.1
      - webexteamssdk==1.6
      - websockets==9.1
      - zict==2.0.0
      - requests-toolbelt==0.9.1
      - requests==2.26.0
      - requests-oauthlib==1.3.0
      - requests-toolbelt==0.9.1`
Enter fullscreen mode Exit fullscreen mode

Given such an env.yml file, we can create a new environment. We’ll use the rasaM1 name for the environment.

conda env create -v --name rasaM1 -f env.yml

Once these dependencies are installed we can active our environment.

conda activate rasaM1

Every time you want you can deactivate you conda enviroment.

Conda deactivate

3. Now we can install Rasa and it's dependencies.

you’ll need to install the Rasa dependencies manually from git. The versions shown below have been tested beforehand and seem to work!

pip install git+https://github.com/vpol/text.git --no-deps
pip install git+https://github.com/RasaHQ/rasa-sdk@3.0.2 --no-deps
pip install git+https://github.com/RasaHQ/rasa.git@3.0.4 --no-deps

Once that is finished you should be able to run Rasa!

Now you can check which version of Rasa is installed.

python -m rasa --version

then you will init a project in directory.

rasa init --no-prompt

and start you rasa chatbot via.

rasa shell

Congratulations! You have successfully installed Rasa Open Source!

Conclusion:
In this article you can learn how to install python and setup to venv enviroment. but we getting error to installing rasa on M1 Macbook So we can setup conda enviroment inspired by this article. you can learn how to set conda enviroment and installing rasa and it's dependencies via github and you can also run you rasa chatbot by following this guide completely.

Top comments (0)