Import module into python not found

1.3k Views Asked by At

I am trying to import the module

import QSTK.qstkutil.qsdateutil as du

But I get the Error

ImportError: No module named QSTK.qstkutil.qsdateutil

My current working directory is

'c:\\Python27\\Lib\\site-packages\\QSTK'

and in the path C:\Python27\Lib\site-packages\QSTK\qstkutil there are the files

qsdateutil.py
qsdateutil.pyc
qsdateutil.pyo
2

There are 2 best solutions below

3
On

Does importing QSTK work?

import QSTK

How about QSTK.qstkutil? If not this is most likely a sys.path problem. Please post the result of:

>>>import sys
>>>sys.path

It should look like:

[ [...], 'C:\Python27\Lib\site-packages', [...] ]

Another thing you can check, is if 'C:\Python27\Lib\site-packages\QSTK\qstkutil' contains a file named '__init__.py'. From the module documentation:

The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.

0
On

try a fresh installation and make sure you run sudo python setup.py install , command after unpack-aging , QSTK. that process links QSTK.qstkutil.qsdateutil.