Path difficulties with Python 2.5 running on Cygwin

Scott David Daniels Scott.Daniels at Acm.Org
Fri May 8 12:44:37 EDT 2009


walterbyrd wrote:
> On May 8, 10:01 am, walterbyrd <walterb... at iname.com> wrote:
>> On May 8, 9:36 am, Jerry Hill <malaclyp... at gmail.com> wrote:
>>
>>> On Fri, May 8, 2009 at 11:29 AM, walterbyrd <walterb... at iname.com> wrote:
>>>> I accidently named a script csv.py, put I deleted that.
>>> You probably still have a stale csv.pyc in that directory.  Delete that too.
> Okay, I got it. I was looking for csv.py - because that is what I
> accidently created. I don't know where csv.pyc came from, unless
> python renamed it that when it tried to load csv.py, or something.

You _need_ to understand where csv.pyc came from, or you will hit
this problem frequently.

When you import any module in python, the python interpreter looks
for a "compiled" version of that mdule -- a .pyc (or when optimizing
.pyo) file.  If it finds it, it checks that it was compiled from the
corresponding .py (or .pyw) file.  If no .pyc is found, or if the
.pyc that was found doesn't match the corresponding .py file, the
.py (or .pyw) file is "compiled into either a .pyc or .pyo, and the
contents of that .pyc or .pyo are used to build the module.

So, importing a module will write a .pyc or .pyo file unless an
appropriate .pyc or .pyo file is found.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list