0

I am studying up on import statements and would like to know the 'search path' where python stores all its modules.

I want to save my own custom module to test run, but from my reading, need to save that module in python's search path or it won't run.

I am using OSX Mavericks.

Thanks!

1 Answers1

0

You can always test your module in the directory where you put the sources, without the need to bring it to Python's search path.

The correct way to deploy your module would be to write a setup script such as described in the Python documentation at https://docs.python.org/2.7/distutils/setupscript.html for Python 2.7.x or at https://docs.python.org/3.5/distutils/setupscript.html for the latest distribution (Python 3.5.1). After you have created the setup script you can run python setup.py develop in your source directory and your module will automatically be installed in the searchpath. See this SO thread to read what happens.

Not recommended (hacky):

With

import sys
print('\n'.join(sys.path))

you will get a full list of all directories python includes in its search path. You can then manually copy your module to one of this directories (you do not want to do this, actually).

Community
  • 1
  • 1
AlexV
  • 578
  • 8
  • 19
  • Thanks Alex - I saved the module in my source directory, with all my other script files, and then imported it into a different script. Did the trick. – SnakeInTheGrass Dec 19 '15 at 20:23