python路径问题:调用zodbconvert时出现ImportError(FreeBSD 8.1)
我猜这是一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您正在使用
buildout
(我希望您是这样),将所有zodbconvert
依赖项正确包含在 python 路径中的最简单方法是使用buildout
code> 为您创建脚本:然后 Buildout 将为您创建一个新的
bin/zodbconvert
脚本,其中包含sys.path
中的所有构建 Egg。或者,您可以创建一个通用的 python 脚本运行程序,其中包含构建中的所有 Egg,并且可以运行任意脚本;您可以使用它而不是简单的 python 解释器来运行任意 python 脚本,其中包含
sys.path
中的所有构建鸡蛋:然后可以使用
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 thezodbconvert
dependencies properly included in the python path is to havebuildout
create the script for you:Buildout then will create a new
bin/zodbconvert
script for you that includes all the buildout eggs insys.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
:The
bin/zopepy
script can then be use to run arbitrary python scripts with all your buildout eggs already insys.path
, sobin/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 yourPYTHONPATH
environment variable.快速修复..
quick fix..
您尚未在 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.