开发者

python path problem: ImportError when calling zodbconvert (FreeBSD 8.1)

I guess this is a python path problem (on FreeBSD 8.1).

Im trying to convert a Data.fs to Postgresql using zodbconvert. Ive downloaded RelStorage-1.5.0b2 and is running:

/usr/local/Plone/Python-2.6/bin/python zodbconvert.py fstodb.conf

, to use the version that Plone is running with.

The error I get:

Traceback (most recent call last):
  File "zodbconvert.py", line 22, in <module>
    from persistent.TimeStamp import TimeStamp
ImportError: No module named persistent.TimeStamp

Versions:

  • Plone 4.0.5 (python 2.6)
  • Postgresql 9.0.3
  • FreeBSD 8.1开发者_JS百科
  • python26-2.6.6_1
  • python27-2.7.1_1

PS by default "python --version" is 2.7.1

Thanks. Nikolaj G.


If you are using buildout (I do hope you are) the easiest way to get all the zodbconvert dependencies properly included in the python path is to have buildout create the script for you:

[buildout]
...
parts =
     ...
     zodbconvert

[zodbconvert]
recipe = zc.recipe.egg
eggs = ${buildout:eggs}
scripts = zodbconvert

Buildout then will create a new bin/zodbconvert script for you that includes all the buildout eggs in sys.path.

Alternatively, you can create a generic python script runner that includes all eggs in your buildout and can run arbitrary scripts; you can use this instead of the bare-bones python interpreter to run arbitrary python scripts with all the buildout eggs in sys.path:

[buildout]
...
parts =
    ...
    zopepy

[zopepy]
recipe = zc.recipe.egg
eggs = ${buildout:eggs}
interpreter = zopepy
scripts = zopepy

The bin/zopepy script can then be use to run arbitrary python scripts with all your buildout eggs already in sys.path, so bin/zopepy zodbconvert.py fstodb.conf should work.

Note that the Plone unified installer already comes with the zopepy part included, and my choice of partname for this script was deliberately using the same name.

If you are not using buildout (and with Plone 4, that's not a good idea on the whole), you can also list the required packages (ZODB3, zope.interface, RelStorage, psycopg2) in your PYTHONPATH environment variable.


quick fix..

locate persistent
export PYTHONPATH=$PYTHONPATH:/path/to/your/python_persistent_dir


You have not included the ZODB package with your Python installation. Either adjust the PYTHONPATH to include the ZODB package or just easy_install ZODB - depending on what you are trying to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜