0

我正在尝试在没有 root 权限的计算机上运行 python 脚本。为此,我virtualenv使用 Python 2.7 设置了一个,然后添加了我需要的两个包 Parallel Python 和 SQLAlchemy。当我运行脚本时,我收到此错误:

(virtPython)thaddeus:recipes ab940$ python2.7 matchIngsParallel.py 
Starting pp with 8 workers
Reading ingredients into dictionary
Traceback (most recent call last):
  File "matchIngsParallel.py", line 65, in <module>
    for synonym, parentIng in session.query(IngSyn.synonym, IngSyn.parentIng): 
  File "build/bdist.macosx-10.6-intel/egg/sqlalchemy/orm/query.py", line 2227, in     __iter__
  File "build/bdist.macosx-10.6-intel/egg/sqlalchemy/orm/query.py", line 2242, in     _execute_and_instances
  File "build/bdist.macosx-10.6-intel/egg/sqlalchemy/engine/base.py", line 1449, in execute
  File "build/bdist.macosx-10.6-intel/egg/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement
  File "build/bdist.macosx-10.6-intel/egg/sqlalchemy/engine/base.py", line 1698, in _execute_context
  File "build/bdist.macosx-10.6-intel/egg/sqlalchemy/engine/base.py", line 1691, in _execute_context
  File "build/bdist.macosx-10.6-intel/egg/sqlalchemy/engine/default.py", line 331, in do_execute
sqlalchemy.exc.OperationalError: (OperationalError) no such table: ingSyns u'SELECT     "ingSyns".synonym AS "ingSyns_synonym", "ingSyns"."parentIng" AS "ingSyns_parentIng" \nFROM     "ingSyns"' ()

似乎所有内容都已正确导入,但未正确访问数据库。

脚本如下:

from assignDB import *
from sqlalchemy.orm import sessionmaker
import pp, sys

ppservers = ()

job_server = pp.Server(ppservers=ppservers)

print "Starting pp with", job_server.get_ncpus(), "workers"

print "Reading ingredients into dictionary"
ingreds = {}
for synonym, parentIng in session.query(IngSyn.synonym, IngSyn.parentIng): 
    ingreds[synonym] = parentIng
print "Finished reading ingredients"

(这段代码被缩短了,但是包含了出错的地方)

assignDB看起来像这样:

from sqlalchemy import Column, Integer, String, ForeignKey, create_engine, Table
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref, sessionmaker
from sqlalchemy.dialects.sqlite import DATETIME, REAL

engine = create_engine('sqlite:///recDB.db')
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()

其次是类定义。

我已经在其他计算机上尝试过这个脚本(但是我有 root 访问权限),包括在其他 virtualenvs 中,它工作正常。我很困惑可能出了什么问题!

4

1 回答 1

1

您的脚本可以正常访问数据库,但其中似乎没有表。我想你从另一台机器上复制了脚本,你也复制了 SQLite 数据库文件recDB.db吗?

于 2012-07-20T11:43:09.987 回答