4

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
arturomp
  • 28,790
  • 10
  • 43
  • 72
  • Check if "c:\\Python27\\Lib\\site-packages" is in the path : print sys.path . Try also to import QQSTK, QSTK.qstkutil – lucasg Sep 13 '13 at 14:35
  • If your current working directory is just `'c:\\'` or something, can you do the import? – Claudiu Sep 13 '13 at 14:40
  • what is your pythonpath? http://stackoverflow.com/a/4855685/2536029 – mnagel Sep 13 '13 at 14:53
  • I tried the print sys.path and got: ['c:\\Users\\thor\\Desktop', 'C:\\Anaconda\\python27.zip', 'C:\\Anaconda\\DLLs', 'C:\\Anaconda\\lib', 'C:\\Anaconda\\lib\\plat-win', 'C:\\Anaconda\\lib\\lib-tk', 'C:\\Anaconda', 'C:\\Anaconda\\lib\\site-packages', 'C:\\Anaconda\\lib\\site-packages\\PIL', 'C:\\Anaconda\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg-info', u'c:\\Python27\\Lib\\site-packages\\QSTK'] – Thor Pajhede Nielsen Sep 13 '13 at 16:00

2 Answers2

2

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.

ThinkChaos
  • 1,803
  • 2
  • 13
  • 21
  • (srry for the poor text quality): import QTSK or QTSK.qstkutil does not work. Runnign sys.path gives ['c:\\Users\\thor\\Desktop', 'C:\\Anaconda\\python27.zip', 'C:\\Anaconda\\DLLs', 'C:\\Anaconda\\lib', 'C:\\Anaconda\\lib\\plat-win', 'C:\\Anaconda\\lib\\lib-tk', 'C:\\Anaconda', 'C:\\Anaconda\\lib\\site-packages', 'C:\\Anaconda\\lib\\site-packages\\PIL', 'C:\\Anaconda\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg-info', u'c:\\Python27\\Lib\\site-packages\\QSTK'] – Thor Pajhede Nielsen Sep 13 '13 at 15:58
  • The path looks fine. Do "import QSTK" and "import QSTK.qstkutil" work? – ThinkChaos Sep 13 '13 at 21:10
  • 2
    sounds like `__init__.py` is missing – qwwqwwq Sep 13 '13 at 22:43
0

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.

leno
  • 1