python - "module 'os' has no attribute 'add_dll_directory'", - Stack Overflow

I am getting the following error while executing my code in AWS Lambda. The code runs file in VSCode.T

I am getting the following error while executing my code in AWS Lambda. The code runs file in VSCode.

The version of pandas i am using :

(.venv) PS C:\code\data_check_lambda> pip show pandas
Name: pandas
Version: 2.2.3

(.venv) PS C:\code\data_check_lambda> python --version
Python 3.11.4

This is the code segment in the python script ( only copying the relevant parts. It works fine when i run in VSCode ( on a windows machine) but gives the error when deployed as AWS Lambda. I have tried different python version 3.11 & 3.9 but same error. :

import pandas as pd

# Convert the items to a DataFrame
df = pd.DataFrame(items)

# Update primary and secondary contact info with names instead of emails

df['primary'] = df['primary'].apply(lambda x: email_to_name(x) if isinstance(x, (str, list)) else x)
df['secondary_contact'] = df['secondary_contact'].apply(lambda x: email_to_name(x) if isinstance(x, (str, list)) else x)

{
"errorMessage": "module 'os' has no attribute 'add_dll_directory'",
"errorType": "AttributeError",
"requestId": "",
"stackTrace": [
"  File \"/var/lang/lib/python3.9/importlib/init.py\", line 127, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n",
"  File \"<frozen importlib._bootstrap>\", line 1030, in _gcd_import\n",
"  File \"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n",
"  File \"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n",
"  File \"<frozen importlib._bootstrap>\", line 680, in _load_unlocked\n",
"  File \"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n",
"  File \"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n",
"  File \"/var/task/lambda_function.py\", line 3, in <module>\n    import pandas as pd\n",
"  File \"/opt/python/pandas/init.py\", line 12, in <module>\n    _delvewheel_patch_1_8_2()\n",
"  File \"/opt/python/pandas/init.py\", line 9, in _delvewheel_patch_1_8_2\n   os.add_dll_directory(libs_dir)\n"]

}

I try using Python 3.9, tried using the PATH variable.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1740316441a4227976.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信