0

如果我只在命令行中导入 pgdb,它工作正常。

直到最近它在 Eclipse 中也可以正常工作(使用完全相同的 Python 2.7.2),但是现在,当我导入 pgdb 时,即使在一个非常简单的文件中(仅包含import pgdb),我也会收到以下错误消息:

Traceback (most recent call last):
  File ".../src/pgdbtest.py", line 8, in <module>
    import pgdb
  File "build/bdist.macosx-10.6-x86_64/egg/pgdb.py", line 66, in <module>
  File "build/bdist.macosx-10.6-x86_64/egg/_pg.py", line 7, in <module>
  File "build/bdist.macosx-10.6-x86_64/egg/_pg.py", line 4, in __bootstrap__
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 908, in resource_filename
    self, resource_name
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1383, in get_resource_filename
    self._extract_resource(manager, self._eager_to_zip(name))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1401, in _extract_resource
    timestamp = time.mktime(date_time)
AttributeError: 'module' object has no attribute 'mktime'

事实上,更一般地说,我发现如果我尝试from time import mktime,我也有错误:

from time import mktime
ImportError: cannot import name mktime
4

1 回答 1

2

好吧,愚蠢的错误:我创建了一个名为“时间”的包......

所以我刚刚删除了它,现在一切都很好。

于 2012-08-20T09:53:31.820 回答