"Christian Witts" <cwi...@compuscan.co.za> wrote
>>> import gun
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gun
>>>
This file is at [/Users/sam/Documents/gun.py]. What should I do to
make it visible to Python?
In the console when you start it up you appear to be in your home
directory `~` but your script is in the Documents folder so you will
need to add Documents to your path for eg.
from sys import path
path.append('/path/to/script/to/be/imported')
import gun
Or you can create/edit your PYTHONPATH environment variable
to include /Users/sam/Documents.
You do that in your ~/.bash_profile file with
export PYTHONPATH=$PYTHONPATH:/Users/sam/Documents
Note the dot before the filename...
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor