Module not found

Peter Otten __peter__ at web.de
Mon Aug 27 13:15:10 EDT 2018


Sharan Basappa wrote:

> I am running a program that I got as reference from GitHub.
> I am running on windows OS.
> 
> Here is a snippet of the code (initial few lines).
> 
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> __author__ = 'Shilin He'
> 
> import sys
> sys.path.insert(0, 'D:\Projects\Initiatives\machine
> learning\loglizer-master\loglizer-master\utils\evaluation')
> sys.path.insert(0, 'D:\Projects\Initiatives\machine
> learning\loglizer-master\loglizer-master\utils\evaluation') print sys.path
> import numpy as np import math
> from scipy.special import expit
> from numpy import linalg as LA
> from scipy.cluster.hierarchy import linkage
> from scipy.cluster.hierarchy import fcluster
> from scipy.spatial.distance import pdist
> import utils.evaluation as ev
> 
> Here is the error:
> D:\Projects\Initiatives\machine
> learning\loglizer-master\loglizer-master\models\log_clustering.py in
> <module>()
>      14 from scipy.cluster.hierarchy import fcluster
>      15 from scipy.spatial.distance import pdist
> ---> 16 import utils.evaluation as ev
>      17
>      18
> ImportError: No module named utils.evaluation
> 
> 
> In the utils directory, I clearly can see evaluation file.
> 
> Can someone give some directions?

(1) The parent directory of the utils directory has to be in sys.path.
(2) If you are using Python 2 you need an __init__.py file in the utils 
directory.




More information about the Python-list mailing list