2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Python / AWS lambda] AWS Lambda実行時にnumpyのRuntime.ImportModuleError

Posted at

エラー内容

Cloudwatch Logsのロググループで確認
[ERROR] Runtime.ImportModuleError: Unable to import module 'src.handlers.filename': 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "/var/lang/bin/python3.9"
  * The NumPy version is: "1.24.1"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy.core._multiarray_umath'

Traceback (most recent call last):

対処

「numpyをinstall(build)するときのpythonのバージョン」と「AWS Lambdaのruntimeに使用するpythonのバージョン」を一致させた。

原因

numpyをinstall(build)したときに使用していたpythonのマイナーバージョンと、AWS Lambdaのruntimeのpythonのマイナーバージョンが異なっていたためにこの問題が発生していた。

今回は、Lambdaのruntimeがpython3.9、numpyをinstall(build)したときのバージョンがpython3.8だった。

numpyは他の多くのpipパッケージとは違い、C言語で書かれたコードのbuildが発生するので、細かな差分があればすぐにエラーになってしまうのだろう( ˘ω˘)スヤァ。。。

参考記事

他にもこんな記事がある模様。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?