Code: Select all
> ImportError: Unable to import required dependencies: numpy: Error
> importing numpy: you should not try to import numpy from
> its source directory; please exit the numpy source tree, and relaunch
> your python interpreter from there. Cannot find module. Please check the requirements.txt file for the missing module. For more info,
Bitte finden Sie unten den Python-Code und andere abhängige Dateien:
function_app.py
Code: Select all
import azure.functions as func
import logging
import json
import pandas
import numpy
import statsmodels.api as sm
from scipy import stats
@app.route(route="health_check", methods=["GET"])
async def health_check(req: func.HttpRequest) -> func.HttpResponse:
# Basic usage of pandas
df = pandas.DataFrame({'A': [1, 2], 'B': [3, 4]})
pandas_result = df.sum().to_dict()
print(pandas_result)
# Basic usage of numpy
np_result = float(numpy.mean([1, 2, 3]))
print(np_result)
# Basic usage of statsmodels
X = [1, 2, 3]
y = [2, 4, 6]
X_const = sm.add_constant(X)
model = sm.OLS(y, X_const)
results = model.fit()
sm_result = float(results.params[1]) # Slope
print(sm_result)
# Basic usage of scipy
scipy_result = float(stats.pearsonr(X, y)[0]) # Correlation
print(scipy_result)
result = {
"pandas_sum": pandas_result,
"numpy_mean": np_result,
"statsmodels_slope": sm_result,
"scipy_correlation": scipy_result
}
return func.HttpResponse(json.dumps(result), status_code=200, mimetype="application/json")
Code: Select all
azure-functions
pandas==2.3.2
numpy==2.2.6
statsmodels==0.14.5
scipy==1.15.3
Code: Select all
py -m pip install --target=".python_packages/lib/site-packages" -r requirements.txt --only-binary=:all: --upgrade --platform manylinux2014_x86_64
Code: Select all
function_app.py
host.json
requirements.txt
.funcignore
.python_packages
Mobile version