kygcoleman
kygcoleman

Reputation: 744

ImportError: No module named RDT

Whether or not this question has been asked before, I apologize. Currently taking a networking class and can't run this RDT python program because modules aren't being imported even though everything is there. PyCharm Program

the instructions from the professor are to run the program and record the results. Program won't run because of this error statement.

ImportError: No module named RTD even though you can clearly see everything is organized and right there. I don't understand why I am having an issue with this. Help? Thanks!

EDIT 1 (Added the import statement)

Import Statement: from RDT import *

Upvotes: 0

Views: 519

Answers (1)

Jeanderson Candido
Jeanderson Candido

Reputation: 364

I have faced this same problem when I renamed some packages on my Python projects on PyCharm. Looking at you file structure, seems like you have several Python projects under the GBN/RDT directory since there are some .idea directories within each folder and if everything was a single project, there should be some __init__.py files on each folder indicating they are Python packages.

If this is the case, try making PyCharm aware that you have several source directories (e.g., PR3R, RDT, etc...)

So proceed with the following steps:

  1. Right-click over one of the sources directories, say, PR3R.
  2. On the dropdown menu, go to Mark directory as
  3. Select Sources roots

Try to execute RDT.py again. I assume you want to execute the script. Repeat this process to the other projects.

However... If you want to import something from one module to another module (e.g. import function foo from Receiver.py in RDT.py), you have to:

  1. Mark RDT (child of GBN) as Sources roots (as I explained previously)
  2. Add __init__.py (which is an empty file that Python uses to know that a given directoy is a package of modules) within RDT and in each child directory (e.g., PR3R, PR3S, and so on....)

Upvotes: 1

Related Questions