how to create a utils.py module

1.4k Views Asked by At

I had a def hello() function in my home/file.py. I created a home/common/utils.pyfile and moved the function there. Then I imported it like this: from utils import hello and the import in my file doesn't throw an error.

The path was also added to my settings.json automatically:

  "python.analysis.extraPaths": [
    "home/common"
  ]

However, when I run the code, it says Runtime.ImportModuleError: Unable to import module 'file': No module named 'utils'

So what's the correct way to create a utils module?

1

There are 1 best solutions below

2
Wojciech Gadaszewski On

in file.py:

from common.utils import hello