这是我尝试运行AWS Lambda函数时遇到的错误。令人窒息的调用是导入wand.image import image
,我将包与其余文件放在同一目录下。我正在运行Windows和python 3.8
{
"errorMessage": "module 'platform' has no attribute 'linux_distribution'",
"errorType": "AttributeError",
"stackTrace": [
" File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n return load_source(name, filename, file)\n",
" File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n module = _load(spec)\n",
" File \"<frozen importlib._bootstrap>\", line 702, in _load\n",
" File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap_external>\", line 783, in exec_module\n",
" File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
" File \"/var/task/event_handler.py\", line 6, in <module>\n from wand.image import Image\n",
" File \"/var/task/wand/image.py\", line 18, in <module>\n from . import assertions\n",
" File \"/var/task/wand/assertions.py\", line 125, in <module>\n from .color import Color # noqa: E402\n",
" File \"/var/task/wand/color.py\", line 10, in <module>\n from .api import library\n",
" File \"/var/task/wand/api.py\", line 161, in <module>\n distname, _, __ = platform.linux_distribution()\n"
]
}
答案 0 :(得分:0)
看起来像platform.linux_distribution
从Python 3.7开始不推荐使用,因此它在Python 3.8中不可用。
请参阅this post
替代方法是使用:
import distro
distro.linux_distribution()
希望有帮助!