Lee-Gihun / MEDIAR

(NeurIPS 2022 CellSeg Challenge - 1st Winner) Open source code for "MEDIAR: Harmony of Data-Centric and Model-Centric for Multi-Modality Microscopy"
MIT License
137 stars 30 forks source link

ModuleNotFoundError: No module named 'train_tools' #13

Closed rmd13 closed 6 months ago

rmd13 commented 8 months ago

Hi, I test the colab demo with no peroblem, however, when I run it as script, error take place: ModuleNotFoundError: No module named 'train_tools' I noticed that train_tools is localized inside Anaconda3\envs\Mediar\Lib\site-packages\MEDIAR, thus that's why the module is not detected.

To solve the problem,I add three lines in the beginning of demo script,:

import os
print("============ getcwd 1=======================")
print(os.getcwd())
aMEDIARroot = "E:\\BackupVIP\\RMD\\GreenSoft\\Anaconda3\\envs\Mediar\\Lib\\site-packages\\MEDIAR"
os.chdir(aMEDIARroot)
print("============ getcwd 2=======================")
print(os.getcwd())

However, the error still persist.

I use a batch file to launch the Anaconda3 and Medira env:

call E:\BackupVIP\RMD\GreenSoft\Anaconda3\Scripts\activate.bat E:\BackupVIP\RMD\GreenSoft\Anaconda3
call conda activate Mediar
call python mediar_demo.py
echo "good"
pause

I also tried add 2 lines the beginning, but it still not work.

E:
cd E:\BackupVIP\RMD\GreenSoft\Anaconda3\envs\Mediar\Lib\site-packages\MEDIAR

I confirmed that both os.getcwd() print the correct path: ============ getcwd 1======================= E:\BackupVIP\RMD\GreenSoft\Anaconda3\envs\Mediar\Lib\site-packages\MEDIAR ============ getcwd 2======================= E:\BackupVIP\RMD\GreenSoft\Anaconda3\envs\Mediar\Lib\site-packages\MEDIAR

but the same error still appears.

Finally, I found that it only works when I place the bat file and mediar_demo.py together inside folder "E:\BackupVIP\RMD\GreenSoft\Anaconda3\envs\Mediar\Lib\site-packages\MEDIAR"

Is there a way to specify the working directory to solve the mising "train_tools" problem? Thanks

rmd13 commented 8 months ago

I add many MEDIAR. to py files that import *, solved.

Lee-Gihun commented 6 months ago

Good to hear that the problem has been solved! The codebase includes several overrides for system paths, so if a path-related issue arises, manual adjustments to the import pipeline may be necessary.