最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin16PV0评论

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far