'A serious "ModuleNotFoundError: No module name..." problem

enter image description here

As the image shows, I have marked the parent directory source root, and pycharm doesn't report an import-error(like wave line or something). In python console, even I can import the packagefedml_api. But when I run it in the terminal, it tells that

ModuleNotFoundError: No Module named 'fedml_api'

BTW, I am running a project in an activated virtual environment called fedml. But the first time I install the venv I made a mistake so that my venv folder is not in my project directory but in a higher one. I don't know whether this is the reason......



Solution 1:[1]

I met the same problem before.

Just cut fedml_api to the parent directory 'site-packages' that works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Etta