Module import in python not found

I am trying to import a module

import QSTK.qstkutil.qsdateutil as du 

But I get an error

 ImportError: No module named QSTK.qstkutil.qsdateutil 

My current working directory

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

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

 qsdateutil.py qsdateutil.pyc qsdateutil.pyo 
+4
source share
2 answers

Does QSTK import work?

 import QSTK 

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

 >>>import sys >>>sys.path 

It should look like this:

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

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

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

+2
source

try a new installation and make sure you run sudo python setup.py install, the command after unpacking, QSTK. this process binds QSTK.qstkutil.qsdateutil.

0
source

Source: https://habr.com/ru/post/1502064/


All Articles