Theodore Escalante
Theodore Escalante

Reputation: 1

Python project structure error while importing

I just started coding in python and I encountered some errors. My text editor (vscode) doesn't show any error while importing the module but whenever I run the code I have encountered it.

So basically, my directory tree looks like this

lib/
|
|-- core/
|    |-- module.py 
|    |-- __init__.py
|    
|         
|-- python/
    |-- server.py
    |-- worker.py
    |-- __init__.py

When I import module.py from python/server.py and use

import lib.core.module

I got an error: No module name lib.core. I tried adding "." but it doesn't work

Upvotes: 0

Views: 118

Answers (1)

ohmchen
ohmchen

Reputation: 67

Try:

from .lib.core.module import *

Upvotes: 1

Related Questions