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

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.

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.

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

Related

Accidentally deleted urllib3 from macOS

I've accidentally deleted/removed the package urllib3 from my python and now when I open terminal, I get this error message.
Traceback (most recent call last):
File "/anaconda2/bin/conda", line 11, in <module>
sys.exit(main())
File "/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 109, in main
from ..exceptions import ExceptionHandler
File "/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 20, in <module>
from .common.url import maybe_unquote
File "/anaconda2/lib/python2.7/site-packages/conda/common/url.py", line 13, in <module>
from .._vendor.urllib3.exceptions import LocationParseError
ImportError: No module named urllib3.exceptions
How can I fix this? Any help would be appreciated.
Edit: I even reinstalled the OS and nothing has changed.!!
Thanks
have you tried pip installing it again:
pip install urllib3
Solved it after numerous trial and error. Taking a closer look, the problem was with anaconda2. So I deleted the entire folder anaconda2 and reinstalled anaconda python 2.7.
Issue is solved.

"No module named zlib" error anytime I use pip

I'm using terminal on mac, and anytime I attempt to use pip, I get the following error message telling me that it cannot find a module named zlib:
$ pip --version
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/local/lib/python3.6/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 36, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
I've read several SO posts with the same error message, and have tried their solutions, including attempting to install zlib using homebrew, which fails, and updating my Xcode developer tools. I also installed pip earlier using python get-pip.py, and it said it installed successfully.
The reason I need pip is to install a package for use on python 2.7, but doing $ pip install "package-name" produces the same error as above. I have both Python 2 and 3 installed on my machine, if that helps. I'm kind of new to pip and using the command line in general, and I'm super confused; if anyone could help me out I'd really appreciate it.
This is the OP. I was able to fix the issue, and wanted to post my solution here in case it would help others.
Essentially I believe it occurred because Python2 is default on my machine, but pip is by default pointing to resources pertaining to Python3, or something like that. Doing pip2 --version instead provided the expected response.

No Module Named pydispatch when using pyOpenGL

I have been attempting to follow a tutorial online and I have followed every single line and for some reason I get the following error:
Traceback (most recent call last):
File "C:/Users/User/Desktop/OpenGLContextTest.py", line 2, in <module>
from OpenGLContext import testingcontext
File "C:\Python27\lib\site-packages\openglcontext-2.2.0a2-py2.7.egg\OpenGLContext\testingcontext.py", line 10, in <module>
from OpenGLContext import plugins, context, contextdefinition
File "C:\Python27\lib\site-packages\openglcontext-2.2.0a2-py2.7.egg\OpenGLContext\context.py", line 32, in <module>
from OpenGLContext import visitor, texturecache,plugins
File "C:\Python27\lib\site-packages\openglcontext-2.2.0a2-py2.7.egg\OpenGLContext\visitor.py", line 3, in <module>
from OpenGLContext.scenegraph import nodepath
File "C:\Python27\lib\site-packages\openglcontext-2.2.0a2-py2.7.egg\OpenGLContext\scenegraph\nodepath.py", line 3, in <module>
from vrml.vrml97 import nodepath, nodetypes
File "C:\Python27\lib\site-packages\pyvrml97-2.3.0a2-py2.7.egg\vrml\vrml97\nodepath.py", line 4, in <module>
from vrml import nodepath
File "C:\Python27\lib\site-packages\pyvrml97-2.3.0a2-py2.7.egg\vrml\nodepath.py", line 3, in <module>
from vrml import node, weaklist
File "C:\Python27\lib\site-packages\pyvrml97-2.3.0a2-py2.7.egg\vrml\node.py", line 6, in <module>
from vrml import field, fieldtypes, weaklist, weakkeydictfix
File "C:\Python27\lib\site-packages\pyvrml97-2.3.0a2-py2.7.egg\vrml\field.py", line 2, in <module>
from pydispatch import dispatcher, robustapply
ImportError: No module named pydispatch
I have attempted searching on google for the chance that this tutorial may be broken or something, but I don't believe it is. I have pydispatch and have attempted to install it using easy_install yet nothing changes. Can someone please help me with this? I know the code is completely correct as after a while I copied and pasted everything to ensure that it wasn't my syntax.
The instructions (apparently incorrectly) say to install pydispatcher. I had the same problem you did until I installed the module PyDispatcher. Confusingly, both exist.
To clarify on #Phil's answer.
I saw:
No module named pydispatch
And so I did:
sudo pip install pydispatch
The install worked, but Scrapy still didn't work because we were supposed to:
sudo pip install pydispatcher
You need to install PyDispatcher separately. Please take a look at the required packages for the tutorial to work along with the installation instructions here:
PyOpenGL Introduction
Check particularly within the section named Package Installation

ubuntu ImportError: cannot import name MAXREPEAT

Upgrade to 13.04 has totally messed my system up .
I am having this issue when running
./manage.py runserver
Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/home/rats/rats/local/lib/python2.7/site-packages/django/core/management
/__init__.py", line 4, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/lib/python2.7/optparse.py", line 77, in <module>
import textwrap
File "/usr/lib/python2.7/textwrap.py", line 10, in <module>
import string, re
File "/usr/lib/python2.7/string.py", line 83, in <module>
import re as _re
File "/home/rats/rats/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/home/rats/rats/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/home/rats/rats/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/home/rats/rats/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
this is happening for both the real environment as well as for virtual environment .
i tried removing python with
sudo apt-get remove python
and sadly it has removed everything .
now google chrome does not show any fonts .
i am looking for getting things back to work .
help is needed for proper configuring it again.
If you are using virtualenvwrapper then you can recreate the virtualenv on top of the existing one (with no environment currently active):
mkvirtualenv <existing name>
which should pull in the latest (upgraded) python version from the system and fix any mismatch errors.
You don't need to recreate the environment.
You can upgrade the virtualenv running this command:
virtualenv /PATH/TO/YOUR_OLD_ENV
YOUR_OLD_ENV folder will be properly upgraded to the version 2.7.4.
I have just solved that problem on my machine.
The problem was that Ubuntu 13.04 use python 2.7.4. That makes conflict with the Python version of the virtualenv.
What I do was to re-create the virtualenv with the new version of python. I think it's the simplest way, but you can try to upgrade the python version without re-creating all of the virtualenv.

ATpy ImportError: No module named astropy.io

I tried to get atpy on python 2.7. I downloaded ATpy0.9.6 from
https://pypi.python.org/pypi/ATpy/0.9.6
then tar it, and run:
cd ATpy0.9.6
sudo python setup.py install
things seemed to work well.
But when I tried to import atpy on python, I got always this error message:
ImportError: No module named astropy.io
More precisely,
>>> import atpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/__init__.py", line 1, in <module>
from .basetable import Table, TableSet, VectorException
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/basetable.py", line 15, in <module>
from . import registry
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/registry.py", line 164, in <module>
from . import fitstable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/fitstable.py", line 8, in <module>
from astropy.io import fits
ImportError: No module named astropy.io
>>>
Could anyone help me to figure out the problem?
Perhaps the 'atpy' package depends on another package called 'astropy.io' that you are missing? Yes here it is https://astropy.readthedocs.org/en/v0.1/index.html
It happens that downloading the tar balls from pypi.python.org is the wrong way to install Python packages. The right way (though the Python docs explain poorly), is to run a command like
pip install atpy
This command will install your package and all its dependencies.
If the command pip is missing, you have to install it, which is ironically really complicated.
In my case the solution was to install astropy
pip install --no-deps astropy

Categories

Resources