Importing local module into Python function fails
See original GitHub issueHello,
I’ve looked at these issues already: #278 and #219 but I keep having an issue when trying to import a local module into a Python function.
I’m using Python 3.7 and not 3.6 so it could be the reason why I can’t get this to work. I’m working on a function created by someone else (with Python 3.6) and I want to run it locally. I have no issues running it but when I try to make an http request I get an error related to the import of a local module.
Here’s my project structure:
functions_python
|_ ml-service
| __init__.py
| model_helper.py
| function.json
I want to import model_helper into init, and here are some of the things I tried:
from . import model_helper (no module named model_helper) from …ml-service import model_helper (Invalid syntax) from functions_python.ml-service import model_helper (Invalid syntax) import functions_python.ml-service (Invalid syntax) from __app__.ml-service import model_helper (Invalid syntax) import __app__.ml-service (Invalid syntax)
The reason I’m trying to import a module is because I have a class in there (used in a sklearn pipeline) and apparently you can’t have it in __init__.py
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
@maiqbal11 I have tried in a Python 3.6 virtual environment and it now works. The issue was indeed linked to the Python version. Do you know if v3.7 will be supported soon?
Thanks for your help
@Kagigz, glad to hear! We need to be able to support both Python 3.6 and 3.7 since many core ML libraries currently have not been ported over to 3.7. This requires some infrastructure work on our part which will happen over the next few months. We are expecting to be able to support 3.7 within the year.