问题
I am trying to use SQLAlchemy
with SublimeText2
and I do the following sequence
Then I do
and thenso my code is
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Transaction(Base):
__tablename__ = 'transaction'
# id = Column('id', Integer, primary_key=True)
id = Column('id', Integer, primary_key=True)
def main():
print 'Hello World!'
if __name__ == '__main__':
main()
When I try to build this as python build i see
line 10, in Transaction
id = Column('id', Integer, primary_key=True)
NameError: name 'Column' is not defined
[Finished in 0.2s with exit code 1]
This is because it does not imports the Column
, Integer
in the file
How can I fix this?
回答1:
My understanding is that SublimeCodeIntel will parse the modules you have imported and make suggestions based on what you've imported. From their github page:
Imports autocomplete - Shows autocomplete with the available modules/symbols in real time.
I don't see anywhere in their documentation where they say it will automatically import modules for you nor have I ever found that functionality myself as I've used it in Sublime Text.
As a side note, using the PyDev plugin with either Aptana Studio or Eclipse gives you a lot of functionality with respect to imports and auto completion, among other things. Granted, you're now using a full blown IDE as opposed to a lightweight text editor, but there are certainly pros and cons to both.
来源:https://stackoverflow.com/questions/15302739/sublimetext2-sublimecodeintel-doesnt-adds-import-even-when-it-suggests