Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python3: import another function in python file: No module named load

In the PyCharm editor, I have a python application named project3 with the following directory structure. The file load.py just has a function (not class py file) def read():, mip.py is a py class file, and has own function method.

 Project
  |
  +---- project1
  |
  +---- project2
  |
  +---- project3
          |
          +---- cnn.py
          +---- load.py
          +---- mip.py

In the cnn.py, I want to import the load and mip file which I intend to use. My import code is as follows;

import load
from mip import f1

But I get the error:

No module named load
Unresolved reference 'mip'
like image 429
tktktk0711 Avatar asked Sep 03 '25 08:09

tktktk0711


1 Answers

In pycharm you must add project3 (and any other directories containing modules) as a root containing sources.

Right click on your project3 directory and in the context menu select: Mark Directory as > Sources Root

like image 198
Sam F Avatar answered Sep 04 '25 21:09

Sam F