question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing SQLAlchemy in Consumption plan

See original GitHub issue

Runtime:

Resource: Azure Function Type: functionapp,Linux

Libraries:

  • Azure Functions version: 1.0.7
  • Func version: 2.7.1948

Description

Having sqlalchemy in my requirements.txt produces the following when I build the function app:

  • running --build local errors with the following:
ERROR: cannot install SQLAlchemy-1.3.12 dependency: binary dependencies without wheels 
are not supported when building locally. Use the "--build remote" option to build 
dependencies on the Azure Functions build server, or "--build-native-deps" option 
to automatically build and configure the dependencies using a Docker container. More 
information at https://aka.ms/func-python-publish
  • running --build remote appears to succeed, but running an endpoint results in a ModuleNotFound: sqlalchemy error in the logs
  • running --build-native-deps appears to succeed, but running an endpoint results in a ModuleNotFound: sqlalchemy error in the logs

SQLAlchemy doesn’t yet issue wheels, and the build code seems to rely on there being a wheel available.

I think SQLAlchemy does some C compilation when it’s built, although I can’t actually remember, but according to the error message I get with --build local, either of these options should work. And neither of them errors. But in that case - why isn’t SQLAlchemy available to the function app?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
borancarcommented, Jul 9, 2020

So, it boils down to Linux Consumption plans not supporting installation from requirements.txt. The package needs to come with all dependencies included. So, you basically have to use func to resolve the dependencies locally and prepare everything. Run:

func azure functionapp publish <....> --build local --build-native-deps

but stop it at:

Running 'docker exec -t 9602cd chmod +x /ziptofs.sh'..done

Then you can zip up the files, making sure to include the generated .python_packages folder as part of your zip package, as that contains all the dependencies.

1reaction
borancarcommented, Jun 5, 2020

I would like to reopen this as I’m having the following issue now when running the Function (with the correct flags applied by my patch to the terraform provider and confirmed within the App Settings). Note that my requirements.txt includes the required eventhub (azure-eventhub==1.3.*):

Exception while executing function: Functions.SessionWriter <--- Result: Failure Exception: ModuleNotFoundError: No module named 'azure.eventhub'
Stack:
    File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 242, in _handle__function_load_request func_request.metadata.entry_point)
    File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/loader.py", line 66, in load_function mod = importlib.import_module(fullmodname)
    File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level)
    File "/home/site/wwwroot/SessionWriter/__init__.py", line 1, in <module> from . import sessionsparser File "/home/site/wwwroot/SessionWriter/sessionsparser.py", line 1, in <module> from . import SessionsWriter
    File "/home/site/wwwroot/SessionWriter/SessionsWriter.py", line 4, in <module> from . import aslogger as logger
    File "/home/site/wwwroot/SessionWriter/aslogger.py", line 2, in <module> from . import EventhubsWriter
    File "/home/site/wwwroot/SessionWriter/EventhubsWriter.py", line 2, in <module> from azure.eventhub import EventHubClient, Receiver, Offset, EventData 
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Install SQLAlchemy - Liquid Web
First, let's look at installing the software within a Python virtual environment. It's best that we create a virtualenv (or venv depending on ......
Read more >
How to Install SQLAlchemy in Python in Windows?
Installing SQLAlchemy on Windows using Conda: ... be done through conda, open up the Anaconda Powershell Prompt and use the below command:
Read more >
How to Install sqlalchemy in Python? - Finxter
Type “ pip install sqlalchemy ” (without quotes) in the command line and hit Enter again. This installs sqlalchemy for your default Python...
Read more >
Download - SQLAlchemy
License. SQLAlchemy is covered by the MIT License. Version Numbering Scheme. All projects within the SQLAlchemy Organization use the same version numbering ...
Read more >
SQLAlchemy - PyPI
pip install SQLAlchemy ... Don't use an ORM if the problem doesn't need one. ... cache query plans effectively and making SQL injection...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found