【发布时间】:2021-07-30 23:06:40
【问题描述】:
我无法使用 AWS Lambda 上的 python3.8 在 AWS Lambda 中导入 numpy 1.19.1
我正在使用以下依赖项:
- 熊猫 1.1.0
- pyarrow 1.0.0
- numpy 1.19.1
- psycopg2 2.8.5
因为我在windows环境下工作,所以我创建了一个安装python3.8的EC2 Linux实例并下载了所有需要的库,然后我将它们添加到项目中,但是当我尝试导入pandas时,我得到以下信息:
[ERROR] ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.8 from "/var/lang/bin/python3.8",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.2" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: No module named 'numpy.core._multiarray_umath'
Traceback (most recent call last):
File "/var/task/src/py38-lib-test.py", line 28, in py38test
import pandas
File "/tmp/lib/pandas/__init__.py", line 16, in <module>
raise ImportError(END RequestId: 07762380-1fc4)
最后,我注意到 AWS Lambda 提供了一个包含 numpy 和 sci-kit 的层,我尝试删除我的 numpy 版本但保留了其余部分并将该层添加到函数中,但发生了同样的错误。
在此先感谢您的 cmets。
【问题讨论】:
-
如果您只使用 AWS 提供的层,而没有您的任何层,它可以工作吗?
-
该库可能与当前的 lambda 运行时不兼容
-
@Marcin,它单独工作,但是当使用 pandas 和 pyarrow 时,它不起作用。我需要他们阅读 .parquet 文件
标签: linux pandas amazon-web-services numpy aws-lambda