Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aweng126 opened this issue Jul 1, 2020 · 6 comments
Closed

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

aweng126 opened this issue Jul 1, 2020 · 6 comments

Comments

@aweng126
Copy link

aweng126 commented Jul 1, 2020

problem description

I was trying to learn lambda function of AWS, I packaged library and source code to a deployment package and upload thme, so I can invoke it .however ,when it comes to the matmul function ,it didn't work, I had try third version of numpy, none of them works, python version is python3.7, numpy version is 1.16,1.18,1.19. the lambda code is very esay,matmul function

import numpy as np
from time import time


def matmul(n):
    A = np.random.rand(n, n)
    B = np.random.rand(n, n)

    start = time()
    C = np.matmul(A, B)
    latency = time() - start
    return latency


def lambda_handler(event, context):
    n = int(event['n'])
    result = matmul(n)
    print(result)
    return result

and this is the log cotent

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': 

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.7 from "/var/lang/bin/python3.7",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.18.0" 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'

END RequestId: c4fc9fea-2802-4ff0-b41c-ec014cad474b
REPORT RequestId: c4fc9fea-2802-4ff0-b41c-ec014cad474b	Duration: 1.57 ms	Billed Duration: 100 ms	Memory Size: 128 MB	Max Memory Used: 50 MB	

is there anybody has idea?

@mattip
Copy link
Member

mattip commented Jul 1, 2020

Duplicate of #13465, see the solutions there, especially this comment that points to this AWS document

@rossbar
Copy link
Contributor

rossbar commented Jul 1, 2020

Perhaps it's worth adding a link on the AWS lambda config to the troubleshooting importerror doc

@rossbar
Copy link
Contributor

rossbar commented Jul 10, 2020

I'm going to close this as duplicate - @aweng126 if you're still having trouble feel free to reopen.

@rossbar rossbar closed this as completed Jul 10, 2020
@aweng126
Copy link
Author

thanks everyone, I think i had found the problem. I zip the code and packages in my Mac, and then I upload the file as function.zip as a lambda function. however, amazon execute your code with linux , the packages installed in mac like numpy have some differences with that installed in linux. so when I launch a ec2 in aws, the problem is fixed.

@shinegit1
Copy link

problem description

I was trying to learn lambda function of AWS, I packaged library and source code to a deployment package and upload thme, so I can invoke it .however ,when it comes to the matmul function ,it didn't work, I had try third version of numpy, none of them works, python version is python3.7, numpy version is 1.16,1.18,1.19. the lambda code is very esay,matmul function

import numpy as np
from time import time


def matmul(n):
    A = np.random.rand(n, n)
    B = np.random.rand(n, n)

    start = time()
    C = np.matmul(A, B)
    latency = time() - start
    return latency


def lambda_handler(event, context):
    n = int(event['n'])
    result = matmul(n)
    print(result)
    return result

and this is the log cotent

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': 

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.7 from "/var/lang/bin/python3.7",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.18.0" 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'

END RequestId: c4fc9fea-2802-4ff0-b41c-ec014cad474b
REPORT RequestId: c4fc9fea-2802-4ff0-b41c-ec014cad474b	Duration: 1.57 ms	Billed Duration: 100 ms	Memory Size: 128 MB	Max Memory Used: 50 MB	

is there anybody has idea?

I am using python 3.9 and my problem was solved by adding aws in-build pandas library in my aws lambda function layer.

@mattip
Copy link
Member

mattip commented Feb 4, 2023

When you say "I packaged library and source code to a deployment package and upload thme" what exactly do you mean? You must package a version of NumPy that can run on the target machine, this is probably what happens when you "add aws in-build pandas library in my aws lambda function layer"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants