python路径问题:调用zodbconvert时出现ImportError(FreeBSD 8.1)

发布于 2024-11-02 23:18:08 字数 698 浏览 4 评论 0原文

我猜这是一个 python 路径问题(在 FreeBSD 8.1 上)。

我正在尝试使用 zodbconvert 将 Data.fs 转换为 Postgresql。我已经下载了 RelStorage-1.5.0b2 并正在运行:

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

,以使用 Plone 运行的版本。

我得到的错误:

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

版本:

  • Plone 4.0.5 (python 2.6)
  • Postgresql 9.0.3
  • FreeBSD 8.1
  • python26-2.6.6_1
  • python27-2.7.1_1

PS 默认情况下“python --version”是 2.7.1

谢谢。 尼古拉·G.

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
  • python26-2.6.6_1
  • python27-2.7.1_1

PS by default "python --version" is 2.7.1

Thanks.
Nikolaj G.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

Oo萌小芽oO 2024-11-09 23:18:08

如果您正在使用 buildout (我希望您是这样),将所有 zodbconvert 依赖项正确包含在 python 路径中的最简单方法是使用 buildout code> 为您创建脚本:

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

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

然后 Buildout 将为您创建一个新的 bin/zodbconvert 脚本,其中包含 sys.path 中的所有构建 Egg。

或者,您可以创建一个通用的 python 脚本运行程序,其中包含构建中的所有 Egg,并且可以运行任意脚本;您可以使用它而不是简单的 python 解释器来运行任意 python 脚本,其中包含 sys.path 中的所有构建鸡蛋:

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

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

然后可以使用 bin/zopepy 脚本使用 sys.path 中已有的所有构建鸡蛋来运行任意 python 脚本,因此 bin/zopepy zodbconvert.py fstodb.conf 应该可以工作。

请注意,Plone 统一安装程序已经附带了 zopepy 部分,并且我为此脚本选择的部分名称是故意使用相同的名称。

如果您不使用 buildout(对于 Plone 4,总体来说这不是一个好主意),您还可以在 buildout 中列出所需的包(ZODB3、zope.interface、RelStorage、psycopg2)代码>PYTHONPATH 环境变量。

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.

铜锣湾横着走 2024-11-09 23:18:08

快速修复..

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

quick fix..

locate persistent
export PYTHONPATH=$PYTHONPATH:/path/to/your/python_persistent_dir
居里长安 2024-11-09 23:18:08

您尚未在 Python 安装中包含 ZODB 包。调整 PYTHONPATH 以包含 ZODB 包或仅包含 easy_install ZODB - 具体取决于您要执行的操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文