سؤال

I'm trying to get autocompletion working in Sublime Text 3 via the Anaconda plug-in. So far I've been successful getting autocompletion working with the standard python libraries but not for Django.

My sublime project file looks like this:

{
  "folders": [
    {
      "follow_symlinks": true,
      "path": "."
    }
  ],

  "settings": {
    "python_interpreter": "/Users/user/.virtualenvs/project/bin/python",
    "suppress_word_completions": true,
    "extra_paths":
    [
        "/Users/user/.virtualenvs/project/lib/python2.7/site-packages"
    ],
    "anaconda_debug": true,
  },

  "build_systems":
    [
        {
            "name":"Virtualenv 2.7 Project",
            "shell_cmd": "/Users/user/.virtualenvs/project/bin/python -u \"$file\"",
            "path": "/Users/jamiehush/.virtualenvs/project/bin",
            "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
            "selector": "source.python"
        }
    ]
}

I'm also running "subl" from a terminal while inside a virtual environment.

هل كانت مفيدة؟

المحلول

You shouldn't need any special extra_path to make autocompleting work with Django. Nothing make Django special, anaconda should be able to autocomplete whatever is visible by your configured python interpreter.

Make sure that the virtual environment in project has a copy of Django installed on it. If you have virtualenwrapper installed should be as easy as:

$ workon project

$ python

import django

If you have Django in your virtualenv, is possible that the anaconda JsonServer was started before you installed the library and it's not able to see it. Restart your Sublime Text 3 and try again.

In case that you still have problems, send an email to the anaconda's mailing list or open an issue in the Github project (https://github.com/DamnWidget/anaconda/issues) indicating your operating system, ST3 build and Python version that you are using so we can help you further.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top