Can't Import a file in different directory using Python
Question: I have a python module at
`/home/amit/folder1/folder2/folder3/folder4/folder5/nbsearch` named
**neighbourhoodsearch.py**. I have included a class in this file in another
module at `/home/amit/folder1/folder2/folder3/folder4/controller` named
**nbsearch_controller.py**.

    
    
    from neighbourhoodsearch import NeighbourhoodSearch
    

I have added the path
`/home/amit/folder1/folder2/folder3/folder4/folder5/nbsearch` to PYTHONPATH
using `sys.path.append` and added a file **__init__.py** in all the folders in
the path. But still when I run the file nbsearch_controller.py, it says

    
    
    ImportError: No module named neighbourhoodsearch
    


Answer: You can try multiple things:

  * triple-check for typos in the path you give
  * print `sys.path` before your problematic `import` and make sure that your path is really there
  * remove `.pyc` files in your directory structure if you have some
  * check the result of `os.path.isfile("/home/amit/folder1/folder2/folder3/folder4/folder5/nbsearch/neighbourhoodsearch.py")` (it should return `True`)

  * check that you have "read" rights on your Python files

