Running Python from bash script causes import errors from custom modules

Viewed 3239

I am running a python script which imports custom functions. My script is named update_wx.py and is located in the weather directory. When I run this from my linux command line as python weather/update_wx.py, it runs fine. However, when I run it as part of a bash script, I receive the following python error:

ModuleNotFoundError: No module named 'weather'

The line within update_wx.py which is causing this error is

from weather.nasa.nasa import import_wx_data

For context, nasa.py is a script within the nasa directory, which is inside the weather directory. As I said, this works when running from the command line. I have checked the file permissions for all files and directories, changed the working directory within the update_wx.py script, and edited the python path in my bash script, all to no avail.

How can I import this python function when running scripts via bash?

Thanks for your help.

1 Answers
Related