Youcompleteme: How can I specify the python used?

Created on 2 Dec 2016  路  10Comments  路  Source: ycm-core/YouCompleteMe

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [x] I have read and understood YCM's CONTRIBUTING document.
  • [x] I have read and understood YCM's CODE_OF_CONDUCT document.
  • [x] I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • [x] If filing a bug report, I have included the output of vim --version.
  • [x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [x] If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • [x] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [x] If filing a bug report, I have included a minimal test case that reproduces
    my issue.
  • [x] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

I have Anaconda installed but I am afraid it is not supported. So I want to know how can I specify the python used with YCM? I just want to use /usr/bin/python.

Most helpful comment

I thought that you were asking how to change the Python used to build YCM but what you really want is to specify the Python used to complete code. By default, YCM completes Python code with the same interpreter as the one used to compile YCM but you can change that with the g:ycm_python_binary_path option. In your case, you could set this option in your vimrc to:

let g:ycm_python_binary_path = '/usr/bin/python'

See the Python Semantic Completion section in the docs for more detail.

You can also change the Python interpreter on the fly with the RestartServer subcommand. For instance, if you want to switch back to Anaconda, you could type the following command while editing a Python file in Vim:

:YcmCompleter RestartServer /path/to/anaconda/interpreter

All 10 comments

I have Anaconda installed but I am afraid it is not supported

No we don't support anaconda.

So I want to know how can I specify the python used with YCM?

Which Python used by YCM are you referring to? Can you elaborate a little?

I have /Users/XXX/anaconda/bin in the PATH, so when I run python it is the anaconda one. But when building and running YCM, I want the python used is /usr/bin/python. How can I do this?

Try the docs?

https://github.com/Valloric/YouCompleteMe#the-gycm_server_python_interpreter-option

I mean the python libraries used when ./install.py. I install YCM with anaconda python and use YCM completing anaconda libraries and everything seems ok. I don't know why.

If everything works fine where is the problem then?

I have /Users/XXX/anaconda/bin in the PATH, so when I run python it is the anaconda one. But when building and running YCM, I want the python used is /usr/bin/python. How can I do this?

YCM is built with the Python used to run the install.py script so if you want regular Python, you should execute the command:

/usr/bin/python install.py

I mean the python libraries used when ./install.py. I install YCM with anaconda python and use YCM completing anaconda libraries and everything seems ok. I don't know why.

We may not support Anaconda but that doesn't mean it's not supposed to work with it.

Thank you. YCM now is perfect in Python completion.

I thought that you were asking how to change the Python used to build YCM but what you really want is to specify the Python used to complete code. By default, YCM completes Python code with the same interpreter as the one used to compile YCM but you can change that with the g:ycm_python_binary_path option. In your case, you could set this option in your vimrc to:

let g:ycm_python_binary_path = '/usr/bin/python'

See the Python Semantic Completion section in the docs for more detail.

You can also change the Python interpreter on the fly with the RestartServer subcommand. For instance, if you want to switch back to Anaconda, you could type the following command while editing a Python file in Vim:

:YcmCompleter RestartServer /path/to/anaconda/interpreter

Okay, I think I didn't convey my thoughts explicitly.

About six months ago, I installed YCM on my MacBook Pro and make clang-completion work perfectly with a brew vim and system python. Then one day, I recover my OS X and install brew vim and brew python (I don't know why brew python is needed, but brew install vim just installs python as well.), and clang-completion with YCM didn't work since then. I doubt it is a python problem but I can't figure it out so I gave up configuring YCM.

Recently, I began to use python and reinstall YCM for python completion. I still can't figure out which python I should use so I came for help. And now, YCM works perfectly.

Thank you all!

I see. The "YCM now is perfect in Python completion" confused me. I am closing the issue then.

Was this page helpful?
0 / 5 - 0 ratings