By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,966 Members | 2,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,966 IT Pros & Developers. It's quick & easy.

error in importing a file in another file

P: 1
i have a file name student which i want to import in modify file i have used
import student
student file has a lot of functions which i want to import
i have even used
from student import *
but in both cases i am getting an error
"no module name student"
Nov 28 '16 #1
Share this Question
Share on Google+
2 Replies

P: 6
This is hacky and even dirty, and in my opinion the language shouldn't impose its way of loading files across the filesystem. In PHP we solved the problem by letting the userland code register multiple autoloading functions that are called when a namespace/class is missing.
Nov 28 '16 #2

Expert 100+
P: 619
import searches the python path, so it can not find the file because it is in some other directory. To print the path, use the code below. You can also add the directory that the file is in to the python path so it searches that directory as well.
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. print sys.path 
Nov 28 '16 #3

Post your reply

Sign in to post your reply or Sign up for a free account.