ModuleNotFoundError: No module named '_brotli' when trying to install dash

Viewed 2066

I try to install dash on a mac OS, and I have the following error when running 'import dash' on a python script:

Traceback (most recent call last):
  File "app.py", line 16, in <module>
    import dash
  File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/__init__.py", line 5, in <module>
    from .dash import Dash, no_update  # noqa: F401,E402
  File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/dash.py", line 17, in <module>
    from flask_compress import Compress
  File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/__init__.py", line 1, in <module>
    from .flask_compress import Compress
  File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/flask_compress.py", line 14, in <module>
    import brotli
  File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/brotli.py", line 8, in <module>
    import _brotli
ModuleNotFoundError: No module named '_brotli'

I can't figure it out what is the problem. I use python 3.7. I saw on the internet a similar issue on windows, but not on mac. I would be really grateful if you could help me.

2 Answers

After uninstalling and installing again brotli it worked! Moreover, working in virtual environments is really more appropriate. Thank you a lot, AKX.

You seem to have a broken installation of the brotli module (missing its native code component _brotli).

Try uninstalling it with pip uninstall brotli, then reinstall it; pip install brotli.

Going forward, I would heavily recommend you learn and use virtualenvs instead of installing everything into your Python's site-packages.

Related