SublimeText2: SublimeCodeIntel doesn't adds import even when it suggests

自闭症网瘾萝莉.ら 提交于 2020-01-25 11:21:12

问题


I am trying to use SQLAlchemy with SublimeText2 and I do the following sequence

Then I do

and then

so 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!