abingham / emacs-ycmd

Emacs client for ycmd, the code completion system.
MIT License
384 stars 46 forks source link

Python 3 ycmd still uses python 2 error checking #497

Closed pjozog closed 5 years ago

pjozog commented 5 years ago

I've compiled ycmd to use python3:

# In git checkout of ycmd:
$ python3 build.py 

I've informed that emacs-ycmd should use python3:

# In .emacs/init.el
(require 'ycmd)
(require 'company-ycmd)
(require 'flycheck-ycmd)
(setq ycmd-server-command (list "python3" (file-truename "~/my-clone-of-ycmd/ycmd")))
(setq ycmd-python-binary-path "/usr/bin/python3")
(ycmd-setup)
(company-ycmd-setup)
(flycheck-ycmd-setup)
(defun enable-ycmd ()
  (ycmd-mode) (company-mode) (flycheck-mode))
(add-hook 'python-mode-hook 'enable-ycmd)

But when I use perfectly valid python3 syntax in a buffer, it throws an error: image

*ycmd-debug-info* is as follows:

Ycmd debug information for buffer test.py in python-mode:

((clang
  (version . "clang version 8.0.0 (tags/RELEASE_800/final)")
  (has_support . t))
 (completer
  (servers)
  (name . "Python")
  (items
   ((key . "Python interpreter")
    (value . "/usr/bin/python3"))
   ((key . "Python path")
    (value . "['/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']"))
   ((key . "Python version")
    (value . "3.5.2"))
   ((key . "Jedi version")
    (value . "0.13.3"))
   ((key . "Parso version")
    (value . "0.3.4"))))
 (python
  (version . "3.5.2")
  (executable . "/usr/bin/python3"))
 (extra_conf
  (path . "/home/paulozog/.ycm_extra_conf.py")
  (is_loaded . t)))

Server is running at: 127.0.0.1:43151

Ycmd Mode is enabled

--------------------

Ycmd version:   1.3snapshot (package: 20190416.807)
Emacs version:  26.1
System:         x86_64-pc-linux-gnu
Window system:  x

The only reason I can get it to work is by by having python point to python3:

$ which python
/usr/bin/python3

Any help would be appreciated, thanks.

pjozog commented 5 years ago

Oh, this isn't a emacs-ycmd issue, it's a flycheck one. My issue is resolved by setting:

(setq flycheck-python-pycompile-executable "/usr/bin/python3")

This setting can be confirmed via flycheck-verify-setup:

Syntax checkers for buffer test.py in python-mode:

First checker to run:

  python-pycompile
    - may enable: yes
    - executable: Found at /usr/bin/python3