How to import custom Python modules to the config.py? #595
-
Hi everyone, currently I was creating a Python module to implement the DataStore interface for a customized RedisStore usage. The redis_store.py file only contains the DataStore implementation (which is currently a WIP):
I imported it to the config.py like this:
But I end up getting ModuleNotFoundError: No module named 'redis_store' Is there a specific way to deal with custom Python modules? Am I mising something? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This "module not found" is typically Python related and can happen for a variety of reasons, though it usually happens when your default directory is not what you think it is. One way to solve this problem is to set the PYTHONPATH environment variable to point to your project directory where all of your "main" python logic is stored. This will force python to check that directory for any modules and packages in its associated subdirectories. You must also ensure that your python package subdirectories have init.py files present (marking the directory as a module). These init.py files can be empty. Hope this helps. |
Beta Was this translation helpful? Give feedback.
This "module not found" is typically Python related and can happen for a variety of reasons, though it usually happens when your default directory is not what you think it is. One way to solve this problem is to set the PYTHONPATH environment variable to point to your project directory where all of your "main" python logic is stored. This will force python to check that directory for any modules and packages in its associated subdirectories. You must also ensure that your python package subdirectories have init.py files present (marking the directory as a module). These init.py files can be empty. Hope this helps.