为什么buildbot抛出ImportError:无法导入名称异常?

时间:2013-06-10 19:37:40

标签: python-2.7 buildbot sqlalchemy-migrate

我目前正在尝试了解buildbot,并且正在浏览tutorial的第一部分。但我被困在我应该创建主人的部分。我尝试使用this网站修复错误,但仍然给我错误。

Traceback (most recent call last):
File "./bin/buildbot", line 5, in <module>
pkg_resources.run_script('buildbot==0.8.7p1', 'buildbot')
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 489, in run_script
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1207, in run_script
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/EGG-INFO/scripts/buildbot", line 4, in <module>
runner.run()
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/buildbot/scripts/runner.py", line 696, in run
subcommandFunction = reflect.namedObject(subconfig.subcommandFunction)
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/Twisted-13.0.0-py2.7- linux-x86_64.egg/twisted/python/_reflectpy3.py", line 151, in namedObject
module = namedModule('.'.join(classSplit[:-1]))
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/Twisted-13.0.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 137, in namedModule
topLevel = __import__(name)
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/buildbot/scripts/create_master.py", line 23, in <module>
from buildbot.db import connector
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/buildbot/db/connector.py", line 22, in <module>
from buildbot.db import pool, model, changes, schedulers, sourcestamps, sourcestampsets
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/buildbot-0.8.7p1-py2.7.egg/buildbot/db/model.py", line 18, in <module>
import migrate.versioning.schema
File "/home/hari/tmp/buildbot/sandbox/lib/python2.7/site-packages/sqlalchemy_migrate-0.7.2-py2.7.egg/migrate/versioning/schema.py", line 10, in <module>
from sqlalchemy import exceptions as sa_exceptions
ImportError: cannot import name exceptions

2 个答案:

答案 0 :(得分:11)

发生此错误because of an incompatibility between SQLAlchemy 0.8+ and sqlalchemy-migrate 0.7.2。您可以通过安装早期版本来解决此问题:

$ pip uninstall sqlalchemy
$ pip install 'sqlalchemy <= 0.7.10'

答案 1 :(得分:3)

转到

 sandbox/lib/python2.7/site-packages/sqlalchemy_migrate-0.*/migrate/versioning/schema.py at line 10

例外更改为 exc ,以便它看起来像

 from sqlalchemy import exc as sa_exceptions