Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol not found: _SASToken_CreateString on Apple Silicon with Azure Functions #278

Open
jimbobbennett opened this issue Sep 30, 2021 · 7 comments

Comments

@jimbobbennett
Copy link

  • UAMQP Package Version: 1.2.14
  • Operating System: macOS Big Sur on Apple M1
  • Python Version: 3.9

Describe the bug
When importing the azure.iot.hub package into an Azure Functions Project, the application throws an ImportError:

Result: Failure
[2021-09-30T19:48:47.531Z] Exception: ImportError: dlopen(/Users/jim/scratch-pad/.venv/lib/python3.9/site-packages/uamqp/c_uamqp.cpython-39-darwin.so, 2): Symbol not found: _SASToken_CreateString
[2021-09-30T19:48:47.531Z]   Referenced from: /Users/jim/scratch-pad/.venv/lib/python3.9/site-packages/uamqp/c_uamqp.cpython-39-darwin.so
[2021-09-30T19:48:47.531Z]   Expected in: flat namespace
[2021-09-30T19:48:47.531Z]  in /Users/jim/scratch-pad/.venv/lib/python3.9/site-packages/uamqp/c_uamqp.cpython-39-darwin.so. Troubleshooting Guide: https://aka.ms/functions-modulenotfound
[2021-09-30T19:48:47.531Z] Stack:   File "/opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3734/workers/python/3.9/OSX/X64/azure_functions_worker/dispatcher.py", line 305, in _handle__function_load_request
[2021-09-30T19:48:47.531Z]     func = loader.load_function(
[2021-09-30T19:48:47.531Z]   File "/opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3734/workers/python/3.9/OSX/X64/azure_functions_worker/utils/wrappers.py", line 42, in call
[2021-09-30T19:48:47.531Z]     raise extend_exception_message(e, message)
[2021-09-30T19:48:47.531Z]   File "/opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3734/workers/python/3.9/OSX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call
[2021-09-30T19:48:47.531Z]     return func(*args, **kwargs)
[2021-09-30T19:48:47.531Z]   File "/opt/homebrew/Cellar/azure-functions-core-tools@3/3.0.3734/workers/python/3.9/OSX/X64/azure_functions_worker/loader.py", line 83, in load_function
[2021-09-30T19:48:47.531Z]     mod = importlib.import_module(fullmodname)
[2021-09-30T19:48:47.532Z]   File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
[2021-09-30T19:48:47.532Z]     return _bootstrap._gcd_import(name[level:], package, level)
[2021-09-30T19:48:47.532Z]   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
[2021-09-30T19:48:47.532Z]   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
[2021-09-30T19:48:47.532Z]   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
[2021-09-30T19:48:47.532Z]   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
[2021-09-30T19:48:47.532Z]   File "<frozen importlib._bootstrap_external>", line 850, in exec_module
[2021-09-30T19:48:47.532Z]   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
[2021-09-30T19:48:47.532Z]   File "/Users/jim/scratch-pad/iot-trigger/__init__.py", line 6, in <module>
[2021-09-30T19:48:47.532Z]     from azure.iot.hub import IoTHubRegistryManager
[2021-09-30T19:48:47.532Z]   File "/Users/jim/scratch-pad/.venv/lib/python3.9/site-packages/azure/iot/hub/__init__.py", line 6, in <module>
[2021-09-30T19:48:47.532Z]     from .iothub_registry_manager import IoTHubRegistryManager
[2021-09-30T19:48:47.532Z]   File "/Users/jim/scratch-pad/.venv/lib/python3.9/site-packages/azure/iot/hub/iothub_registry_manager.py", line 6, in <module>
[2021-09-30T19:48:47.532Z]     from . import iothub_amqp_client
[2021-09-30T19:48:47.532Z]   File "/Users/jim/scratch-pad/.venv/lib/python3.9/site-packages/azure/iot/hub/iothub_amqp_client.py", line 23, in <module>
[2021-09-30T19:48:47.532Z]     import uamqp
[2021-09-30T19:48:47.532Z]   File "/Users/jim/scratch-pad/.venv/lib/python3.9/site-packages/uamqp/__init__.py", line 12, in <module>
[2021-09-30T19:48:47.532Z]     from uamqp import c_uamqp  # pylint: disable=import-self

To Reproduce
Steps to reproduce the behavior:

  1. Create an Azure Functions project
  2. Add azure-iot-hub to the requirements.txt file, create a virtual environment and install the packages from this file
  3. Import from azure.iot.hub in the __init__.py file

You can find a project to reproduce this here: https://github.com/jimbobbennett/iot-func-error

Expected behavior
It should work and not thrown an exception.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@yunhaoling
Copy link
Contributor

hey @jimbobbennett , apologize for the late response and thanks for the link to your repo.

the uamqp doesn't provide apple M1 yet (arm-based) wheel yet, we only support wheels for x86 & x86-64, which means on Apple M1, the library uamqp-python (based on uamqp-c) will need to build itself first which requires extra dependencies.

Are you working with the Apple M1 for local development? one workaround you could try locally is to put cython into the requirements.txt of the Azure Function to see if it helps the compilation of the library on your Apple M1.

@jimbobbennett
Copy link
Author

@yunhaoling - tried that, same error.

@SiddyP
Copy link

SiddyP commented Nov 8, 2021

Hi @jimbobbennett perhaps this could work?
I develop azure functions locally and to get around import issues with uamqp I create the venv and install the dependencies using Rosetta. I haven't tried it with azure-iot-hub though.

@trevors20
Copy link

@yunhaoling, thanks for the info. Would you know of a timeline when uamqp would support Apple M1?

@GuMiner
Copy link

GuMiner commented Mar 17, 2022

I was running into this problem even when building directly from the source. I had to add the following line in setup.py on line 172 when cmakeing azure-uamqp-c, so that azure-uamqp-c would be built universal.

""-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64"",

@tonyjune
Copy link

I am facing the same issue. Anything we can do as a temporary fix?

@jooskesters
Copy link

jooskesters commented Sep 21, 2022

pip uninstall uamqp
pip install uamqp --no-binary uamqp

found the solution here:
https://apple.stackexchange.com/questions/436801/m1-mac-mach-o-file-but-is-an-incompatible-architecture-have-x86-64-need-a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants