Python Error when importing azure-eventhub on Mac Monterey - python

I am trying to import following:
from azure.eventhub import EventData
from azure.eventhub.aio import EventHubProducerClient
from azure.eventhub.exceptions import EventHubError
I get error:
from azure.eventhub import EventData
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/__init__.py", line 5, in <module>
from ._common import EventData, EventDataBatch
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_common.py", line 24, in <module>
from ._utils import (
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_utils.py", line 33, in <module>
from uamqp import types as uamqp_types
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/__init__.py", line 12, in <module>
from uamqp import c_uamqp # pylint: disable=import-self
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/c_uamqp.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SASToken_CreateString'
>>> from azure.eventhub.aio import EventHubProducerClient
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/__init__.py", line 5, in <module>
from ._common import EventData, EventDataBatch
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_common.py", line 24, in <module>
from ._utils import (
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_utils.py", line 33, in <module>
from uamqp import types as uamqp_types
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/__init__.py", line 12, in <module>
from uamqp import c_uamqp # pylint: disable=import-self
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/c_uamqp.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SASToken_CreateString'
>>> from azure.eventhub.exceptions import EventHubError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/__init__.py", line 5, in <module>
from ._common import EventData, EventDataBatch
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_common.py", line 24, in <module>
from ._utils import (
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/azure/eventhub/_utils.py", line 33, in <module>
from uamqp import types as uamqp_types
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/__init__.py", line 12, in <module>
from uamqp import c_uamqp # pylint: disable=import-self
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uamqp/c_uamqp.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_SASToken_CreateString'
PS- I already did pip install for azure-eventhub. I am running this on Mac M1 machine, with Python: 3.10.6 and pip 22.2.2.
What needs to be fixed/imported to resolve the error?

Try installing uamqp from source instead of wheel/binary.
Remove the eventhub and uamqp libraries first:
pip remove azure-eventhub
pip remove uamqp
Install uamqp from source first:
pip install --no-binary uamqp uamqp
pip install azure-eventhub
This worked for me on my M1. See if this works for you as well.

On Python 3.10 you can update to the latest uamqp package to get Apple M1 support:
pip install -U uamqp
Version 1.6.1 and above will support M1 on Python 3.10 and later

I wanted to provide an update. My team just released a new version of the Event Hubs SDK which is using a new AMQP stack written all in Python and removes the dependency on uamqp. This allows us to support the SDK on multiple platforms with no breaking changes. You can pip install azure-eventhub >= 5.11.0 to get the latest version. For further information please see the announcement and the readme for backwards compatibility with uamqp

Related

Pip isn't working after downgrading to version 18

I downgraded Pip from the most recent version using sudo python -m pip install pip==18.0 --upgrade, and now I am receiving the following error when running pip/pip3, including when trying to re-upgrade it using pip3 install --upgrade pip
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in \<module\>
from pip.\_internal import main
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_internal/__init__.py", line 42, in \<module\>
from pip.\_internal import cmdoptions
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_internal/cmdoptions.py", line 16, in \<module\>
from pip.\_internal.index import (
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_internal/index.py", line 14, in \<module\>
from pip.\_vendor import html5lib, requests, six
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/__init__.py", line 25, in \<module\>
from .html5parser import HTMLParser, parse, parseFragment
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/html5parser.py", line 8, in \<module\>
from . import \_tokenizer
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_tokenizer.py", line 16, in \<module\>
from .\_trie import Trie
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_trie/__init__.py", line 3, in \<module\>
from .py import Trie as PyTrie
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_trie/py.py", line 6, in \<module\>
from .\_base import Trie as ABCTrie
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/\_vendor/html5lib/\_trie/\_base.py", line 3, in \<module\>
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)
Not sure if there's a specific reason you installed pip 18.0 as it looks incompatible with Python 3.10. It looks like in Python 3.10 collections.Mapping moved to collections.abc.Mapping. I would suggest just completely uninstalling pip and reinstalling, without using pip to do so.
In general, you should try to use the latest version of pip.

ImportError: cannot import name 'registry' from 'pandas.core.dtypes.base'

I just did a conda install of a few packages to follow a tutorial, and now I can't even import pandas.
I installed these:
fake-factory==0.7.2
Faker==0.7.3
pytz==2016.7
tzlocal==1.3.0
And now I get this:
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\api.py", line 7, in <module>
from pandas.core.arrays.integer import (
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\__init__.py", line 2, in <module>
from .base import (ExtensionArray, # noqa
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\base.py", line 21, in <module>
from pandas.core import ops
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\ops\__init__.py", line 21, in <module>
from pandas.core.construction import extract_array
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\construction.py", line 18, in <module>
from pandas.core.dtypes.base import ExtensionDtype, registry
ImportError: cannot import name 'registry' from 'pandas.core.dtypes.base' (C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\dtypes\base.py)
I tried doing a conda update pandas, but to no avail.
I also just installed luigi, not quite sure when it broke as I installed all the additional packages in one go.
Updated version of pandas package using pip3
try this in python3
pip3 install --upgrade pandas
Try updating pandas package in Anaconda:
conda install pandas=1.1.4
If no luck, try updating all packages:
conda update --all
Worked in my case.

Import librosa gives "no module named numba.decorators", how to solve?

I installed librosa, and now im trying to import it
import librosa
This throws me this error for some reason
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\__init__.py", line 12, in <module>
from . import core
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\__init__.py", line 125, in <module>
from .time_frequency import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\time_frequency.py", line 11, in <module>
from ..util.exceptions import ParameterError
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\__init__.py", line 77, in <module>
from .utils import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\utils.py", line 15, in <module>
from .decorators import deprecated
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\decorators.py", line 9, in <module>
from numba.decorators import jit as optional_jit
ModuleNotFoundError: No module named 'numba.decorators'
Why am i getting this error even after installing the library?
You have to install numbra version 0.48 because of a bug, run
pip install numba==0.48
Librosa Issue on Github
You need to use any numba version before 0.8.0
However, the most recent librosa is not compatible with any numba below 0.48.
At least, that's what I've found from using it on Windows. My solution was to use google colaboratory as it didn't give me any error when importing librosa.
I've got the exact error. Solved it with
pip uninstall --yes librosa
pip install librosa --force-reinstall
Your python version should be 3.8.

Pycharm : package Pycurl installed but not found (ModuleNotFoundError)

I installed pycurl for python3
but when I want to import it to Pycharm and use it I get this error message:
Traceback (most recent call last):
File "/home/cours/PycharmProjects/untitled2/venv/test.py", line 1, in <module>
import pycurl
ModuleNotFoundError: No module named 'pycurl'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "/home/cours/PycharmProjects/untitled2/venv/test.py", line 1, in <module>
import pycurl
ModuleNotFoundError: No module named 'pycurl'
But when I install it with the Pycharm terminal (pip install pycurl) I get this message
Requirement already satisfied: pycurl in /usr/lib/python3/dist-packages (7.43.0.1)
I also already imported the package with : Settings -> Python Interpreter
And finally i also used : "Inherit global site-package" option of the project and the problem is the same
I have no idea what else i can do
use command this command to install package -
pip3 install pycurl
and also check the Pycharm python version in for code compile

Jupyter install for Python 2.7 failed

I have the Anaconda distribution of Python 2.7 and I needed to install the Jupyter notebook package. During the installation process my computer turned off and after that I couldn't continue with the process. I tried to uninstall Jupyter and try installing it again, but I keep getting the same error:
Traceback (most recent call last):
File "C:\Users\Acer\Anaconda\Scripts\ipython-script.py", line 3, in <module>
from IPython import start_ipython
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\__init__.py", line 49, in <module>
from .terminal.embed import embed
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\terminal\embed.py", line 19, in <module>
from IPython.terminal.ipapp import load_default_config
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\terminal\ipapp.py", line 22, in <module>
from IPython.core.completer import IPCompleter
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\core\completer.py", line 71, in <module>
from IPython.utils import generics
File "C:\Users\Acer\Anaconda\lib\site-packages\IPython\utils\generics.py", line 8, in <module>
from simplegeneric import generic
ImportError: No module named simplegeneric
What should I remove/add in order to make it work?
You need to install the python package simplegeneric. After you install it, you need to install the next package that you fail to import. Continue this process until you dont get any import errors.

Categories