LBM
LBM

Reputation: 31

Python can't locate modules which I have created

I am new to programming and have recently installed the Enthought Canopy distribution and can't seem to import certain modules.

Python 2.7 MacOSX

Numpy works when I import it, however other modules which I have created or downloaded as a simple module.py file return this error message:

import numfun1
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-297-cb46e477a372> in <module>()
----> 1 import numfun1

ImportError: No module named numfun1

Could it have something to do with where those modules are saved? If so, how do I point python in their direction? or where should I put those modules so that Python sees them.

Thank you in advanced for your suggestions.

Upvotes: 1

Views: 79

Answers (2)

cdonts
cdonts

Reputation: 9599

If you create a module you must put it where your script is.

Upvotes: 0

R&#246;rd
R&#246;rd

Reputation: 6681

Information about the module search path is included in the official Python tutorial: http://docs.python.org/2/tutorial/modules.html#the-module-search-path.

A lot of python libraries come with a setup.py script that will automatically install them into locations that are on the search path.

The installation process can be even more automated by using a Python package manager like pip.

Upvotes: 3

Related Questions