ShadowClone icon indicating copy to clipboard operation
ShadowClone copied to clipboard

Runtime deploy fails: Error importing numpy

Open m0pam opened this issue 1 year ago • 3 comments

I tried to fix this for many many hours, without results. :disappointed:

TLDR:

Unable to import module 'handler.entry_point': Error importing numpy: you should not try to import numpy from\n its source directory; please exit the numpy source tree, and relaunch\n your python interpreter from there.

Verbose:

(env) testss@pc8:~/ShadowClone$ lithops runtime deploy sc-runtime --memory 512 --timeout 300
2024-11-24 19:01:52,193 [INFO] config.py:139 -- Lithops v3.4.1 - Python3.11
2024-11-24 19:01:52,193 [DEBUG] config.py:101 -- Loading configuration from /home/testss/.lithops/config
2024-11-24 19:01:52,198 [DEBUG] config.py:179 -- Loading Serverless backend module: aws_lambda
2024-11-24 19:01:52,220 [DEBUG] config.py:220 -- Loading Storage backend module: aws_s3
2024-11-24 19:01:52,220 [DEBUG] aws_s3.py:36 -- Creating AWS S3 Client
2024-11-24 19:01:52,256 [INFO] aws_s3.py:59 -- S3 client created - Region: eu-north-1
2024-11-24 19:01:52,390 [DEBUG] aws_lambda.py:53 -- Creating AWS Lambda client
2024-11-24 19:01:52,575 [INFO] aws_lambda.py:97 -- AWS Lambda client created - Region: eu-north-1
2024-11-24 19:01:52,576 [INFO] aws_lambda.py:448 -- Deploying runtime: sc-runtime - Memory: 512 Timeout: 300
2024-11-24 19:01:53,157 [DEBUG] aws_lambda.py:165 -- Ok --> function "lithops-worker-removed-xxx-removed" is active
2024-11-24 19:01:53,157 [DEBUG] aws_lambda.py:516 -- OK --> Created lambda function lithops-worker-removed-xxx-removed
2024-11-24 19:01:53,157 [DEBUG] aws_lambda.py:700 -- Extracting runtime metadata from: sc-runtime
Traceback (most recent call last):
  File "/home/testss/ShadowClone/env/bin/lithops", line 8, in <module>
    sys.exit(lithops_cli())
             ^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/lithops/scripts/cli.py", line 523, in deploy
    runtime_meta = compute_handler.deploy_runtime(runtime_name, runtime_memory, runtime_timeout)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/lithops/serverless/serverless.py", line 84, in deploy_runtime
    return self.backend.deploy_runtime(runtime_name, memory, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/lithops/serverless/backends/aws_lambda/aws_lambda.py", line 531, in deploy_runtime
    runtime_meta = self._generate_runtime_meta(runtime_name, memory)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/testss/ShadowClone/env/lib/python3.11/site-packages/lithops/serverless/backends/aws_lambda/aws_lambda.py", line 714, in _generate_runtime_meta
    raise Exception(f'An error occurred: {result}')
Exception: An error occurred: {'errorMessage': "Unable to import module 'handler.entry_point': Error importing numpy: you should not try to import numpy from\n        its source directory; please exit the numpy source tree, and relaunch\n        your python interpreter from there.", 'errorType': 'Runtime.ImportModuleError', 'requestId': '', 'stackTrace': []}

This was probably the 3rd or 4th fatal error in the process of attempting to get the tool working, although each time I managed to fix the issue, it looks like the tool isn't really maintained anymore? :thinking:

m0pam avatar Nov 24 '24 19:11 m0pam

it should work with the latest requirements.txt I pushed last week

fyoorer avatar Nov 24 '24 21:11 fyoorer

HI @fyoorer. I just installed the tool and I'm having the exact same issue described here.

OmarE-G avatar Mar 05 '25 14:03 OmarE-G

@OmarE-G Did you by any chance need to update the Python version in the Dockerfile to match your local version? If so make sure you updated it in both relevant spots - only setting one will cause this error. (Just made this mistake myself!)

You'll need to rebuild and redeploy the image after fixing this if so.

pizzeys avatar Mar 08 '25 06:03 pizzeys