January 10th, 2014, 02:43 PM
Import error - new to python
I'm new to python and am trying to just get some basic stuff up and going.
I have a very basic module called foo
It's in the following directory on my machine
In that folder is __init__.py (created automatically) and foo.py
foo.py looks like this
If I open up command prompt and do following it works:
def __init__(self, name, number):
self.name = name
self.number = number
However, if I run this from C:\ I get the following
I thought, well maybe it's a system error
>>> import sys
['', 'C:\\Python33', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 'C:\\workspace', 'C:\\Windows\\system32\\python33.zip',
However, that seems OK.
Is there something I'm missing?
January 10th, 2014, 11:14 PM
You really ought to start out your DOS commands with
A:> cd where\ever\I\put\my\python\module\this\is\a\path
[/code] are essential for python code and Makefiles!
January 14th, 2014, 04:25 PM
You could do ...
sys.path.append('C:/workspace/PyFoo/src/foo' ) at the beginning of your program.
Note, Windows can use '/' instead of '\'
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25