+ 3

How can I import a module from another directory?

I am just working on a program.So I made different directory. File/Main.py File/Bin/func.py I tried to import func to main just like this way.. import os os.chndir("D:/Programs/Files/Bin") import func But It showes error.. How can I solve it..

27th Apr 2017, 12:20 PM
Khan Asfi Reza Pranto
Khan Asfi Reza Pranto - avatar
2 Answers
+ 11
try putting a r before the string like: dstring=r"D:/Whatever/FoxPictures/fox.py" that might not fix it, but I've had problems like it in the past where that's the solution
27th Apr 2017, 1:02 PM
Ahri Fox
Ahri Fox - avatar
+ 1
should i try import os os.chdir("D:/Programs/Files") from Files import func.py
27th Apr 2017, 3:11 PM
Khan Asfi Reza Pranto
Khan Asfi Reza Pranto - avatar