Python Data source and PIP install new libraries

Issue Summary

I have installed a new python library via pip on the redash server docker container:

pip install hl7
The install is successful and shows when I run:
pip list
I then created the python data source:
image
when I try to import the new module that was just installed I get:
Error running query: <class ‘ModuleNotFoundError’> No module named ‘hl7’

Does redash need to be reloaded after new python libraries are installed

Technical details:

  • Redash Version: 10.1.0 (2589bef1)
  • Browser/OS:Chrome
  • How did you install Redash: Docker via docker-compose

Queries are executed on the worker services, not the server service. If you didn’t pip install hl7 on the workers then you’ll see this import error.

Thanks Jesse. That did the trick. I install the package on the worker, adhoc_worker and the schedule_worker.

Glad to hear that worked. Just keep in mind that if you bounce the containers in the future you may need to reinstall this package. To guarantee the dependency is installed you can write your own Dockerfile that extends our image.

Understood. Proof of concept testing at this point to see if we can get functionality to parse raw hl7 as a data source with redash. The proof of concept works up till I try to return the data frame in a json format and the to_json pandas function breaks the query.

Interesting. What kind of error do you get?

Depending on the complexity of your needs it might make sense to create your own query runner for this data. particularly if you’ll have many queries that contain the same boilerplate just to get the data into Redash’s format.

I actually got it sorted. The to_json was the issue as I had already created a json type structure for the rows.

see the code and the result below:

1 Like

Thanks for posting your follow-up. I’m sure that will help future searchers :smiley: