Reputation: 55
The question is quite straight forward. As told by the Python doc, the site package should be automatically imported during initilization. but this is not the case for me. I have to import it mannually to make it work using this:
import site
site.main()
Also, I'm sure that the directory python\lib which contains site.py is in the search path. And I'm using windows 7.
I'm wondering what is wrong here if any one knows...
Upvotes: 1
Views: 146
Reputation: 184385
It's undeniably imported at startup, as you can easly verify:
import sys
print sys.modules["site"].__file__
That doesn't mean any name has been imported into your namespace. To do that, you must use import
. Since the module has already been imported once, you'll get a reference to that module:
import site
assert site is sys.modules["site"]
In other words, it works like any other module that is imported in some module other than your own.
There's actually not any point in calling site.main()
, as it's already been called during the import.
Upvotes: 2