I have a module I have installed called lts_fits
, and this is its path:
~/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/lts_fits
So it is clearly in the site packages folder. Within this folder, there is a python script:
lts_linefit.py
Yet when I have this line of code in my script:
from lts_fits import lts_linefit
I get this error:
ImportError: No module named lts_fits
How? It's clearly in there, and I have tried this same syntax with other random scripts and they import just fine. For instance, a file abc.py
located in the folder ~/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sympy
imports just fine when I have the line from sympy import abc
. What could be going wrong?
You need an __init__.py
file in that directory (you do not have to put anything into the file, all you need to do is create it).
The easiest way to create said file is by using:
touch __init__.py
from within your lts_fits
directory in your command line/terminal/console.
See this SO article: What is __init__.py for?
And the Python Documentation for packages.