this question has answer here:
- importing files in python? 5 answers
i trying import file python shell. have read multiple answers on site same question asked other users, none of them have worked.
the command type is:
import filename.py
i have tried typing:
from filename import *
in idle clicked file -> path browser make sure file saved in 1 of folders.
am doing steps wrong?
look here: importing files in python?
credit pradyun excellent answer:
if working in same directory, is, b.py in same folder a.py, unable reproduce problem (and not know why problem occurs), helpful if post os.getcwd() returns b.py.
if that's not case, add on top of b.py
import sys sys.path.append('path a.py')
or if in same path,
import sys sys.path.append(os.basename(sys.argv[0])) # should there anyway still..
please further research before posting answer.
Comments
Post a Comment