Running Rasa in Pycharm debugger

I’m trying to run Rasa (not Action server, but Rasa itself) in PyCharm debugger. I an executing rasa module with “run --enable-api --debug --endpoints endpoints.yml” as parameters.

It runs, but clients cannot connect to it. I have tried both socketio and facebook, and they have the same error:

[2019-08-17 12:27:14 -0700] [2918] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/socket.io/?EIO=3&transport=polling&t=MoX357R'
Traceback (most recent call last):
  File "/Users/michael/Documents/projects/rasa2/env/lib/python3.6/site-packages/sanic/app.py", line 893, in handle_request
    handler, args, kwargs, uri = self.router.get(request)
  File "/Users/michael/Documents/projects/rasa2/env/lib/python3.6/site-packages/sanic/router.py", line 407, in get
    return self._get(request.path, request.method, "")
  File "/Users/michael/Documents/projects/rasa2/env/lib/python3.6/site-packages/sanic/router.py", line 469, in _get
    raise NotFound("Requested URL {} not found".format(url))
sanic.exceptions.NotFound: Requested URL /socket.io/ not found

Has anyone has success with this?

Note that it works fine when running in terminal.

Hi @mmm3bbb, could you post the contents of your endpoints.yml file, as well as the full output of the run command when you run it with --debug? Thanks.

Hi @fede. OK, it was a working directory problem. Your hint to look at --debug helped me figure that out. Thx. However, I do get this message with an error at the end. It still runs though.

/Users/michael/Documents/projects/rasa2/env/bin/python /Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py --module --multiproc --qt-support=auto --client 127.0.0.1 --port 59740 --file rasa run --enable-api --debug --endpoints endpoints.yml --credentials credentials.yml
pydev debugger: process 65995 is connecting

Connected to pydev debugger (build 191.6605.12)
2019-08-19 10:50:06 INFO     engineio.server  - Server initialized for sanic.
2019-08-19 10:50:06 DEBUG    rasa.core.utils  - Available web server routes: 
/conversations/<conversation_id>/messages          POST                           add_message
/conversations/<conversation_id>/tracker/events    POST                           append_events
/webhooks/rasa                                     GET                            custom_webhook_RasaChatInput.health
/webhooks/rasa/webhook                             POST                           custom_webhook_RasaChatInput.receive
/webhooks/rest                                     GET                            custom_webhook_RestInput.health
/webhooks/rest/webhook                             POST                           custom_webhook_RestInput.receive
/model/test/intents                                POST                           evaluate_intents
/model/test/stories                                POST                           evaluate_stories
/conversations/<conversation_id>/execute           POST                           execute_action
/webhooks/facebook                                 GET                            fb_webhook.health
/webhooks/facebook/webhook                         GET                            fb_webhook.token_verification
/webhooks/facebook/webhook                         POST                           fb_webhook.webhook
/domain                                            GET                            get_domain
/socket.io                                         POST                           handle_request
/                                                  GET                            hello
/model                                             PUT                            load_model
/model/parse                                       POST                           parse
/conversations/<conversation_id>/predict           POST                           predict
/conversations/<conversation_id>/tracker/events    PUT                            replace_events
/conversations/<conversation_id>/story             GET                            retrieve_story
/conversations/<conversation_id>/tracker           GET                            retrieve_tracker
/webhooks/socketio                                 GET                            socketio_webhook.health
/status                                            GET                            status
/model/predict                                     POST                           tracker_predict
/model/train                                       POST                           train
/model                                             DELETE                         unload_model
/version                                           GET                            version
2019-08-19 10:50:06 INFO     root  - Starting Rasa server on http://localhost:5005
2019-08-19 10:50:06 INFO     root  - Enabling coroutine debugging. Loop id 140693200207896.
2019-08-19 10:50:06 DEBUG    rasa.model  - Extracted model to '/var/folders/wk/ynmgx56s43xcfzq2cc3_nmw40000gn/T/tmpdxi6qxa5'.
2019-08-19 10:50:48 INFO     rasa.nlu.components  - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-en'.
2019-08-19 10:50:48 DEBUG    rasa.core.tracker_store  - Connected to InMemoryTrackerStore.
2019-08-19 10:50:48 DEBUG    rasa.model  - Extracted model to '/var/folders/wk/ynmgx56s43xcfzq2cc3_nmw40000gn/T/tmpts0_pyp1'.
2019-08-19 10:50:49 DEBUG    pykwalify.compat  - Using yaml library: /Users/michael/Documents/projects/rasa2/env/lib/python3.6/site-packages/ruamel/yaml/__init__.py
2019-08-19 10:51:08 ERROR    asyncio  - exception in Task.__repr__
handle: <Handle <TaskStepMethWrapper object at 0x14036fdd8> created at /usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/tasks.py:519>
task: Exception in __repr__ AttributeError("'NoneType' object has no attribute 'co_filename'",); value type: <class '_asyncio.Task'>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 121, in uvloop.loop.Handle._format_handle
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_tasks.py", line 15, in _task_repr_info
    coro = coroutines._format_coroutine(task._coro)
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py", line 323, in _format_coroutine
    filename = coro_code.co_filename
AttributeError: 'NoneType' object has no attribute 'co_filename'

Glad you were able to solve the directory problem. So now it runs, but you can’t actually use it, correct?

I found that the biggest ‘gotcha’ was setting the interpreter to use. Assuming you’ve created an environment to run rasa in and you’ve downloaded the code, when you open the rasa project you must set the Python interpreter in settings to something as below:

As you can see I used conda and setup a rasa environment. All the dependencies needed to run rasa have been loaded into it. this was confirmed by being able to rasa run from the installed directory.

Here is a screenshot of Pycharm configuration to debug.

let me know if you face problem configuring it.

mmm3bbbMichael Bell:

Hi I am pretty new to Rasa and Pycharm. Can you please help me learn how to set the debugger environments in Pycharm.

I have added a screenshot in the above link. Could you please follow it and let me know where you are stuck?

1 Like

thank you Lohith, Followed the same. But still no success, any way we can have a PM. I can share my screen, for you to have a quick look, if you can help me. Will be interested to learn from you.

I have actually written an article around running/debugging Rasa in PyCharm - here is the link in case this helps anyone looking: Running and Debugging Rasa Applications in an IDE | by Daniel Cahall | Jul, 2021 | Medium

This is how the rasa action server is configured

i am getting this error: prompt_toolkit.output.win32.NoConsoleScreenBufferError: No Windows console found. Are you running cmd.exe?