samleoqh / MSCG-Net

Multi-view Self-Constructing Graph Convolutional Networks with Adaptive Class Weighting Loss for Semantic Segmentation
MIT License
68 stars 28 forks source link

problem ModuleNotFoundError: No module named 'lib.loss' #4

Closed DmitriySheverda closed 4 years ago

DmitriySheverda commented 4 years ago

Hello, what might be the problem? Traceback (most recent call last): File "C:\Users\Dmitriy\Desktop\MSCG-Net-master\tools\train_R50.py", line 10, in from lib.loss.acw_loss import * ModuleNotFoundError: No module named 'lib.loss'

samleoqh commented 4 years ago

Try to use the command as below: $ PYTHONPATH=${PWD}/..:${PYTHONPATH} CUDA_VISIBLE_DEVICES=0 python train_R50.py

DmitriySheverda commented 4 years ago

If I use Windows, CUDA 10.0, Anaconda, python 3.6.9 is installed. will your program work on Windows? If you know, please tell me what the problem may be? The problem with ""ModuleNotFoundError: No module named 'lib.loss'"" is still relevant.

samleoqh commented 4 years ago

I tried it on my Windows system. it works well. I run the train_R50.py with PyCharm IDE. If you train with windows powershell by using the below command like :

python .\tools\train_R50.py

python will try to import lib.loss from the wrong path .\tools\lib\loss\acw_loss.py. That is the problem. No module named lib.loss under the folder of .\tools. One solution for this case, you can add one line code in train_R50.py ... import sys sys.path.append(".") # this code will correct the wrong path issue in windows ...

samleoqh commented 4 years ago

Another way to solve the problem if you don't want to change the code. You can try run it using the command in windows powershell like:

..\MSCG-Net> python -m tools.train_R50.py

samleoqh commented 4 years ago

Please refer to this link: https://stackoverflow.com/questions/33862963/python-cant-find-my-module