[Zope] zope and PYTHONPATH
Kalyan Jammigumpula
kalyan at srcc.lsu.edu
Mon Sep 20 14:40:32 EDT 2004
> Kalyan Jammigumpula wrote at 2004-9-20 10:18 -0500:
>> File "/home/accts/zope/srcczope/Products/plots/plots.py", line 3, in ?
>> from mx import DateTime
>>ImportError: cannot import name DateTime
>
>
> This means, it found an "mx" but it did not contain "DateTime".
>
> Check which "mx" was found and why there is no "DateTime" there...
>
That was it Dieter. Thank you very much. What was happening was zope's
python had mx with Tidy and other modules but no DateTime. Our local
instance of python had mx's DateTime module installed. So, it was
finding mx from the zope's python but not DateTime.
However, the PYTHONPATH problem remains. For the other modules in
python's local instance and not present in zope's python unlike mx, I
need to set python's sys.path in every python file I need to import them
which is annoying. What I do now is I import sys and do
sys.path = sys.path + ['PATHNAMES I NEED']
That seems to work fine and I have no ImportErrors. My idea of
PYTHONPATH was to basically avoid this and that's what I think
PYTHONPATH is there for.
From what I read on zope.org mailing list (keywork PYTHONPATH),
somebody had said to look at the pathnames in sys.path and compare them.
When I print sys.path in zopectl.py, I see all the pathnames I need.
However, by the time zope imports my half-baked product, the pathnames I
need and I set using PYTHONPATH are not there anymore. That to me was a
little odd. I really appreciate your help regarding this. Thank you very
much. It has helped me understand ImportErrors a little better.
-Kalyan
More information about the Zope
mailing list