[Zope] zope and PYTHONPATH

Kalyan Jammigumpula kalyan at srcc.lsu.edu
Mon Sep 20 11:18:50 EDT 2004


All-
I run Plone2 over zope2.7 on a linux box.
We have multiple python intances on our linux box.
As zope is very picky about the python version, we have a python 
instance only for a zope. Also, we have our own applications in python 
(unrelated to zope) which need 3rd party modules. For that we have a 
different python binary at a different location.

 From zope's python I want to use the modules we developed and installed 
on the other python intance. So, I added the 
/usr/lib/python2.2/site-packages, the python for our local use, to 
PYTHONPATH by exporting PYTHONPATH from bash_profile. Invoking the 
script from the command line with zope's python works without an import 
error. However, zope/Plone combo wont startup with zopectl if I use one 
of those modules in a basic zope product I am trying to develop. It 
throws an ImportError. Am I missing something? Isnt it supposed to work 
that way?

I realized maybe I need to make that change to PYTHONPATH in zope's 
startup script. So, I have changed the "zopectl" used to start 
zope+plone now, and printed the PYTHONPATH by using "env | grep 
PYTHONPATH" in the zopectl script. It is being set to what I want. 
However, the ImportError persists from zope's startup.
I am surprised why it works, when I run the script that does the import, 
from the commandline and why it wont from zope's startup although the 
same PYTHONPATH is being set.

The error being thrown.

2004-09-20T10:03:36 ERROR(200) Zope Could not import Products.plots
Traceback (most recent call last):
   File "/home/accts/zope/Zope-2.7.0/lib/python/OFS/Application.py", 
line 654, in import_product
     product=__import__(pname, global_dict, global_dict, silly)
   File "/home/accts/zope/srcczope/Products/plots/__init__.py", line 1, in ?
     import plots
   File "/home/accts/zope/srcczope/Products/plots/plots.py", line 3, in ?
     from mx import DateTime
ImportError: cannot import name DateTime
Traceback (most recent call last):
   File "/home/accts/zope/Zope-2.7.0/lib/python/Zope/Startup/run.py", 
line 49, in ?
     run()
   File "/home/accts/zope/Zope-2.7.0/lib/python/Zope/Startup/run.py", 
line 19, in run
     start_zope(opts.configroot)
   File 
"/home/accts/zope/Zope-2.7.0/lib/python/Zope/Startup/__init__.py", line 
51, in start_zope
     starter.startZope()
   File 
"/home/accts/zope/Zope-2.7.0/lib/python/Zope/Startup/__init__.py", line 
230, in startZope
     Zope.startup()
   File "/home/accts/zope/Zope-2.7.0/lib/python/Zope/__init__.py", line 
46, in startup
     _startup()
   File "/home/accts/zope/Zope-2.7.0/lib/python/Zope/App/startup.py", 
line 45, in startup
     OFS.Application.import_products()
   File "/home/accts/zope/Zope-2.7.0/lib/python/OFS/Application.py", 
line 631, in import_products
     import_product(product_dir, product_name, raise_exc=debug_mode)
   File "/home/accts/zope/Zope-2.7.0/lib/python/OFS/Application.py", 
line 654, in import_product
     product=__import__(pname, global_dict, global_dict, silly)
   File "/home/accts/zope/srcczope/Products/plots/__init__.py", line 1, in ?
     import plots
   File "/home/accts/zope/srcczope/Products/plots/plots.py", line 3, in ?
     from mx import DateTime
ImportError: cannot import name DateTime


More information about the Zope mailing list