Linux 无法在AWS Lambda中导入numpy 1.19.1,没有名为';numpy.core._multiarray_umath';

Linux 无法在AWS Lambda中导入numpy 1.19.1,没有名为';numpy.core._multiarray_umath';,linux,pandas,amazon-web-services,numpy,aws-lambda,Linux,Pandas,Amazon Web Services,Numpy,Aws Lambda,我无法在AWS Lambda中导入numpy 1.19.1,在AWS Lambda上导入python3.8 我正在使用以下依赖项: 熊猫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 impo

我无法在AWS Lambda中导入numpy 1.19.1,在AWS Lambda上导入python3.8

我正在使用以下依赖项:

  • 熊猫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)
[错误]导入错误:无法导入所需的依赖项:
努比:
重要提示:请阅读本文,了解如何解决此问题的建议!
导入numpy c扩展失败。
-尝试卸载并重新安装numpy。
-如果您已经这样做了,那么:
1.检查您是否希望从“/var/lang/bin/Python3.8”使用Python3.8“,
在你的路径或PYTHONPATH中没有可以
干扰您尝试使用的Python和numpy版本“1.18.2”。
2.如果(1)看起来不错,您可以在
https://github.com/numpy/numpy/issues.  请详细说明:
-您是如何安装Python的
-你是如何安装numpy的
-您的操作系统
-是否安装了多个版本的Python
-如果您是从源代码构建的,那么您的编译器版本和理想情况下的构建日志
-如果您正在使用numpy git存储库,请尝试使用`git clean-xdf`
(删除所有不受版本控制的文件)并重新生成numpy。
注意:这个错误有很多可能的原因,所以请不要评论
关于此的现有问题-打开一个新的。
最初的错误是:没有名为“numpy.core.\u multiarray\u umath”的模块
回溯(最近一次呼叫最后一次):
文件“/var/task/src/py38 lib test.py”,第28行,在py38test中
进口大熊猫
文件“/tmp/lib/pandas/_init__uuu.py”,第16行,在
提出请求(结束请求ID:07762380-1fc4)
最后,我注意到AWS Lambda提供了一个带有numpy和sci工具包的层,我尝试删除我的numpy版本,但保留了其余版本,并将该层添加到函数中,但出现了相同的错误


提前感谢您的评论。

您的ec2实例是amazon linux2机器吗?您还可以尝试为AmazonLinux2构建和运行docker映像,并通过将卷装载到主机上,使python libs与Lambda中所需的环境兼容

类似于docker lambda的东西:


AWS Lambda函数不能以这种方式工作。如果你打开Pandas软件包,它会有Numpy软件包,但它们不会工作。 简单的解决方案是首先根据您的python版本和工作环境从站点分别下载所需的包,解压缩它们并将它们添加到您的项目目录中。创建项目的.zip并将其部署到AWS Lambda函数上。这样就行了。
您可以参考站点以遵循完整的过程。

如果您只使用AWS提供的层,而不使用您的层,它是否工作?库可能与当前的lambda不兼容runtime@Marcin,它单独起作用,但当使用pandas和pyarrow时,它不起作用。我需要他们阅读一个.parquet文件。我想这就是问题所在(linux版本),它对我来说很复杂,因为环境非常严格。我不能使用docker,甚至不能正确使用软件。团队中有人不知何故获得了正确的库,我们能够使用它们。谢谢你的帮助