umihico / docker-selenium-lambda

The simplest demo of chrome automation by python and selenium in AWS Lambda
MIT License
535 stars 127 forks source link

Can't import other python files in same directory #151

Closed morgan-young closed 1 year ago

morgan-young commented 1 year ago

Hey. I'm using this and trying to import functions from another file in the same directory as main.py, but I get this error:

"errorMessage": "Unable to import module 'main': No module named 'ssm_parameter_store'" (ssm_parameter_store.py is the name of the file).

in main.py I have the import statement likefrom ssm_parameter_store import SSMParameterStore. I have also tried import ssm_parameter_store and I get the same issue. I have also tried with other files.

This is the same syntax I use for all other python stuff including serverless but this doesn't work. How can I import other python files with this Docker setup please?

Thanks

morgan-young commented 1 year ago

I solved this by writing explicit COPY statements in the Dockerfile for the other files.

For example instead of just:

COPY main.py ./

I also put

COPY my_other_file.py ./