I followed Jessica Hamrick's emacs setup before adding evil. This means that there is a lot of specific configuration issues in my ~/.emacs.d/ which I don't necessarily understand, shame on me, but specifically I have checked that both python-mode and auto-complete were installed using el-get, and yet the python-mode-hook complains that it does not know about ac-source-pycomplete:

auto-complete error: (void-variable ac-source-pycomplete)

The symbol is explicitly added (with other symbols) to ac-sources as part of 'python-mode-hook, because pycomplete thinks it's clever enough for all auto-completion tasks and removes all other sources from the ac-sources.

(add-hook 'python-mode-hook
      (lambda ()
         (setq ac-sources '(ac-source-pycomplete

How do I get Emacs to know pycomplete in a clean-ish way?

  • No need to quote lambdas. – Drew Aug 7 '16 at 14:41
  • It seems that when python-mode-hook is run (when python-mode is enabled) ac-source-pycomplete has not yet been defined, which suggests that library autocomplete (or wherever ac-source-pycomplete is defined, if not by autocomplete) has not yet been loaded. Try (require 'autocomplete) before enabling python-mode. – Drew Aug 7 '16 at 14:44
  • (require 'auto-complete) is run by init.el and works in other modes. I don't start with any buffers in python-mode, so the -hook is definitely run later than auto-complete is loaded, unless I'm missing something crazy. – Anaphory Aug 7 '16 at 15:29
  • In that case, it would seem that auto-complete.el does not define ac-source-pycomplete. As I said, "wherever ac-source-pycomplete is defined" - that library needs to be loaded before ac-source-pycomplete is, well, defined (not void). Find our what that library is, and load it before trying to use python-mode. – Drew Aug 7 '16 at 18:12
  • It appears that 'ac-source-pycomplete is defined in python-mode/completion/auto-complete-pycomplete.el. It appears that even though I installed python-mode through el-get, it did not get added to the load-path, but everything else did. Curious. – Anaphory Aug 7 '16 at 18:33

When python-mode-hook is run (when python-mode is enabled) ac-source-pycomplete has not yet been defined, which indicates that the library where ac-source-pycomplete is defined has not yet been loaded.

Find out what that library is and ensure that you load it (e.g. using require) before you enable python-mode.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.