0
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?

AWS Lambda LayersでError importing numpy: you should not try to import numpy from its source directory

Posted at

AWS Lambda LayersでError importing numpy

AWS Lambda Layersでlangchainを使おうとして以下のエラーが発生しました。

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.
Traceback (most recent call last):

Keith's Layers (Klayers) のnumpyをレイヤーに追加して解決する。

numpyのARNを確認

Klayersへ遷移

対象Pythonバージョン選択

例えば、Python 3.12を選ぶと以下が開きます。
https://github.com/keithrozario/Klayers/tree/master/deployments/python3.12

対象Region選択

例えば、ap-northeast-1 Asia Pacific (Tokyo)htmlを選ぶと以下が開きます。
https://api.klayers.cloud/api/v2/p3.12/layers/latest/ap-northeast-1/html

対象パッケージARNコピー

今回はnumpyarnをコピーします。

レイヤー追加

あとはAWS Lambdanの対象関数へ戻り、レイヤー レイヤーを追加 ARN を指定 でコピーしておいたARNを貼り付けて追加すればOK。

0
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
0
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?