corochann / SeRanet

Super Resolution of picture images using deep learning
MIT License
84 stars 10 forks source link

ModuleNotFoundError: No module named 'src' #7

Open kikiki1121 opened 5 years ago

kikiki1121 commented 5 years ago

I want to do network learning. ・Create data / Training_images ・Place my data set in Training_images ・Run  python src / train.py -a seranet_v1 -g 0 I attempted learning by the above procedure. However, I got an error. ModuleNotFoundError: No module named 'src' I studied variously and tried changing it myself, but I could not solve it

corochann commented 5 years ago

I way is to execute script from this project root OK: SeRanet$ python src/inference.py input.jpg NG: src$ python inference.py input.jpg

corochann commented 5 years ago

Second way is to set PYTHONPATH

$ export PYTHONPATH=path-to-seranet-directory:$PYTHONPATH

please modify path-to-seranet-directory properly according to your environment.

kikiki1121 commented 5 years ago

Is it the same for train.py? Also, export command is not recognized and pythonpath can not be changed

corochann commented 5 years ago

Yes, it is same for train.py. Can you copy and paste from the line where you execute the code, until get the end of error message?

SeRanet$ python src/train.py
kikiki1121 commented 5 years ago

D:\SeRanet-master>python src/train.py -a seranet_v1 -g 0 prepare model Traceback (most recent call last): File "src/train.py", line 71, in import arch.seranet_v1 as model_arch File "D:\omichi\SeRanet-master\src\arch\seranet_v1.py", line 9, in import src.functions as CF ModuleNotFoundError: No module named 'src'

I get the above error.

corochann commented 5 years ago

I see you are using windows. How about this?

D:\SeRanet-master> set PYTHONPATH=D:\SeRanet-master
D:\SeRanet-master> python src/train.py
kikiki1121 commented 5 years ago

() D:\SeRanet-master>set PYTHONPATH=D:\SeRanet-master

() D:\SeRanet-master>python src/train.py -a seranet_v1 -g 0 prepare model Traceback (most recent call last): File "src/train.py", line 71, in import arch.seranet_v1 as model_arch File "D:\SeRanet-master\src\arch\seranet_v1.py", line 9, in import src.functions as CF ModuleNotFoundError: No module named 'src'

I get the above error.

corochann commented 5 years ago

Well,,, in that case how about adding the following code in top of train.py? (please modify and try execute it).

import sys
import os
sys.path.append(os.pardir)
sys.path.append(os.path.join(os.pardir, os.pardir))
kikiki1121 commented 5 years ago

I changed train.py. However, the same error came out.

corochann commented 5 years ago

oh i see... that's wired. what kind of environment you are trying? In default windows command line?

kikiki1121 commented 5 years ago

Running using anaconda command line is used.

corochann commented 5 years ago

I only tried with normal windows command line.

Anyway, the problem should be in PYTHONPATH setting. So If you are using anaconda command line, could you refer this to set correct configuration? https://stackoverflow.com/questions/43099096/setting-pythonpath-on-windows-under-anaconda-without-elevated-privileges/43402606

Gajender0707 commented 1 year ago

I am facing the same issue but I don't know how to fix it... my error is

PS C:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test> & C:/python/python.exe c:/Users/asdf/Documents/D.S/END-TO-END-PROJECTS/Test/src/exception2.py Traceback (most recent call last): File "c:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test\src\exception2.py", line 2, in from src.logger import logging ModuleNotFoundError: No module named 'src' PS C:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test>

I have a folder named test in which src and in src there is logger and exception but i'm not able to import logger from src

ghost commented 4 months ago

I am facing the same issue but I don't know how to fix it... my error is

PS C:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test> & C:/python/python.exe c:/Users/asdf/Documents/D.S/END-TO-END-PROJECTS/Test/src/exception2.py Traceback (most recent call last): File "c:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test\src\exception2.py", line 2, in from src.logger import logging ModuleNotFoundError: No module named 'src' PS C:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test>

I have a folder named test in which src and in src there is logger and exception but i'm not able to import logger from src

Did u solve this error?? I need help

Gajender0707 commented 4 months ago

I used another approach for this

On Sun, May 26, 2024 at 12:05 PM Kshitija Chilbule @.***> wrote:

I am facing the same issue but I don't know how to fix it... my error is

PS C:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test> & C:/python/python.exe c:/Users/asdf/Documents/D.S/END-TO-END-PROJECTS/Test/src/exception2.py Traceback (most recent call last): File "c:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test\src\exception2.py", line 2, in from src.logger import logging ModuleNotFoundError: No module named 'src' PS C:\Users\asdf\Documents\D.S\END-TO-END-PROJECTS\Test>

I have a folder named test in which src and in src there is logger and exception but i'm not able to import logger from src

Did u solve this error?? I need help

— Reply to this email directly, view it on GitHub https://github.com/corochann/SeRanet/issues/7#issuecomment-2132088672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWDDN5AEEAIXEOENUH47YWLZEF7DHAVCNFSM4GKEJP22U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJTGIYDQOBWG4ZA . You are receiving this because you commented.Message ID: @.***>