6

I am new in Python and pycharm ide. I have created one of my own module and importing it in another python file. Both of my python files are in same direcotary and parent directory has been made Sources Root directory.

Now my program is working fine but pycharm ide is showing error in import statement and on hover prompting no such module.

I am not sure if i am doing something wrong please let me know what is the proper way to import a module.

here is my project structure - Main.py is importing Greeting.py and getting error.test is a root directory. Main.py

Greeting.py

prashant sindhu
  • 1,769
  • 2
  • 15
  • 25

2 Answers2

8

For my case, I had my problem was not resolved by invalidating the cache, My problem was with the directories (packages) and the root directory. Here was my structure.

MyApp:
|
|----my_first_app
|--------my_first_app_files
|--------my_first_app_directories
|----my_second_app
|--------my_second_app_files
|--------my_second_app_directories

So what I did on my editor was I right clicked app:>mark directory as:>sources root

Referrence

Link

Fahd Jamy
  • 365
  • 6
  • 7
3

invalidate cache and restart resolved the problem.

jetbrains.com/help/pycharm/cleaning-system-cache.html

Community
  • 1
  • 1
prashant sindhu
  • 1,769
  • 2
  • 15
  • 25