简体   繁体   中英

Sublime Text 2 autocompletion for python

I have installed both and , but I am not getting the autocompletion from imported library. ,但是我没有从导入的库中获取自动全功能。

What do I need to do to get available methods from imported library, say MySQLdb in Sublime Text 2? In Pycharm, if I import a library, I get all the available methods from that library as suggestion like from Google search. But this is not the case in Sublime Text. Is there any other plugin I have to install to get this feature?

My best advice would be to upgrade to Sublime Text 3 and use Anaconda for code completion. ST3 has a number of new features over ST2, and behind the scenes, the API has a bunch of changes that make writing and supporting plugins very easy - unfortunately, some of the changes are backwards-incompatible. ST2 includes Python 2.6 internally, while ST3 includes Python 3.3, so developers essentially either need to support two separate codebases, or have a lot of ugly if ST2: do this; else: do that if ST2: do this; else: do that type of constructs. The result of this is that a lot of plugin authors have chosen to only support ST3, meaning there are many more packages available for ST3 than ST2, and this includes Anaconda . The "beta" version of ST3 (currently build 3065) is just as stable as ST2. If you're a registered user (and you should be!), you have access to the bleeding-edge development builds (build 3081 was just released some hours ago), which have a ton of new features, but are sometimes less stable. I've been using ST3 exclusively (unless I need to test something on ST2) for well over a year now, and haven't had any issues at all.

As far as Anaconda goes (it has no relation whatsoever with the Anaconda Python distribution), I just love it. I used to use SublimeCodeIntel , but it was a little tough to configure, took a long time to index files, and oftentimes just didn't work well, if at all. Anaconda uses static analysis to figure out the type of your variables, and provides the appropriate methods and attributes via autocomplete. All you need to do is specify where Python lives on your machine, and it will automatically configure itself to use the standard lib for that version, as well as any 3rd-party modules you may have installed. It can be configured independently via .sublime-project files, so you can use different interpreter versions depending on the project you're working on - it also works with virtualenvs. Finally, it provides built-in linting via PEP8, PyLint, and/or PEP257, if you are so inclined (I just turn it off, as I think it's annoying, but it can be very helpful for novice coders). Aside from the fact that it just works, Anaconda 's best feature is that it's entirely asynchronous, so it won't slow down ST3 or crash it if it has an unrecoverable error. I've never had it crash on me, through, another reason I like it.

Finally, just in case you were wondering, I have no connection to the Anaconda project at all, other than a single pull request that removed one character - I'm just a very satisfied user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM