Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ModuleNotFoundError: No module named 'SLCT'

English is not my mother tongue, so there might be some grammatical errors in my question.
Sorry about that.

I git clone a project from github to my VScode. When I wanted to run demo code, a "ModuleNotFoundError" occured. I was confused about this error. Because I checked module and it did exit, I also haven’t install same name module before.
Here is the project-tree of the project.(Only parts including "SLCT" are given)

source code
└─ logparser_root
   ├─ benchmark
   │  ├─ SLCT_benchmark.py
   ├─ demo
   │  ├─ SLCT_demo.py
   ├─ logparser
   │  ├─ SLCT
   │  │  ├─ cslct.c
   │  │  ├─ cslct.h
   │  │  ├─ README.md
   │  │  ├─ SLCT.py
   │  │  ├─ __init__.py
   │  │  └─ __pycache__
   │  │     └─ __init__.cpython-39.pyc

"SLCT_demo.py" import SLCT from logparser.

import sys
import os
# sys.path.append('../')
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
# sys.path.append('../logparser//SLCT//SLCT.py')
# print(sys.path)
from logparser import SLCT

When I ran "SLCT_demo.py", this error occured.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Traceback (most recent call last):
  File "c:\Users\57142\Desktop\Project files\source code\logparser_root\demo\SLCT_demo.py", line 9, in <module>
    from logparser import SLCT
  File "c:\Users\57142\Desktop\Project files\source code\logparser_root\logparser\SLCT\__init__.py", line 1, in <module>
    from SLCT import *
ModuleNotFoundError: No module named 'SLCT'

Here is "init.py" of "SLCT".
from SLCT import *
Thanks for spending time on my question. Have a nice day!

>Solution :

In order to run from SLCT import * inside file x.py, you need to have the following directory structure:

File x.py
Folder SLCT
- File __init__.py

In your case, you are trying to run from SLCT import * inside file __init__.py, which means that you need to have the following directory structure:

File __init__.py
Folder SLCT
- File __init__.py

And in your case, since this whole thing is already inside a folder named SLCT, you’re probably caught in your own confusion.

In short, it sounds like you want to simply move the entire contents of file SLCT.py into file __init__.py (although it’s hard to say for sure, because you haven’t made the rest of your code visible).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading