简体   繁体   中英

Import module into python not found

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM