"YouCompleteMe unavailable: requires python 2.x" message despite Python 2.x being installed #35

Closed
stuartmemo opened this Issue Feb 5, 2013 · 20 comments

Comments

Projects
None yet
@weaksauce

This comment has been minimized.

Show comment
Hide comment
@weaksauce

weaksauce Feb 5, 2013

check the output of

:python <<eof import sys print(sys.version) eof

if it throws an error you don't have python installed for vim.

check the output of

:python <<eof import sys print(sys.version) eof

if it throws an error you don't have python installed for vim.

@Valloric

This comment has been minimized.

Show comment
Hide comment
@Valloric

Valloric Feb 5, 2013

Owner

Yeah, you need python2 support in Vim, not just in your system.

Owner

Valloric commented Feb 5, 2013

Yeah, you need python2 support in Vim, not just in your system.

@Valloric Valloric closed this Feb 5, 2013

@reklis

This comment has been minimized.

Show comment
Hide comment
@reklis

reklis Feb 12, 2013

macports has a python27 variant, you can install via sudo port install macvim +python27

reklis commented Feb 12, 2013

macports has a python27 variant, you can install via sudo port install macvim +python27

@jProvim

This comment has been minimized.

Show comment
Hide comment
@jProvim

jProvim Oct 26, 2013

If you installed your vim and macvim and python used homebrew, you might refer the following link.
This is a work-around solution.

Gist:
cd /System/Library/Frameworks/Python.framework/Versions
sudo mv Current Current-sys
sudo ln -s /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7 Current

brew install macvim
#brew reinstall macvim

sudo mv Current Current-brew
sudo mv Current-sys Current

I tested and verified with OS X 10.9.

ref: http://superuser.com/questions/461845/how-can-i-use-the-homebrew-python-with-homebrew-macvim-on-mountain-lion

Another possible solution: http://superuser.com/questions/440981/how-can-i-use-the-homebrew-python-version-with-homebrew-macvim-on-snow-leopard

jProvim commented Oct 26, 2013

If you installed your vim and macvim and python used homebrew, you might refer the following link.
This is a work-around solution.

Gist:
cd /System/Library/Frameworks/Python.framework/Versions
sudo mv Current Current-sys
sudo ln -s /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7 Current

brew install macvim
#brew reinstall macvim

sudo mv Current Current-brew
sudo mv Current-sys Current

I tested and verified with OS X 10.9.

ref: http://superuser.com/questions/461845/how-can-i-use-the-homebrew-python-with-homebrew-macvim-on-mountain-lion

Another possible solution: http://superuser.com/questions/440981/how-can-i-use-the-homebrew-python-version-with-homebrew-macvim-on-snow-leopard

@guileen

This comment has been minimized.

Show comment
Hide comment
@guileen

guileen Jan 14, 2014

I have python 2.6, I also get this error.

guileen commented Jan 14, 2014

I have python 2.6, I also get this error.

@neitanod

This comment has been minimized.

Show comment
Hide comment
@neitanod

neitanod Sep 9, 2014

I want to clone my dotfiles folder (that include the plugins I use) into several remotes where I'm not root, and some of them don't have Python 2.
What I am trying to achieve is a highly portable configuration.
Is there a way of degrading gracefully and start Vim without the error message?

neitanod commented Sep 9, 2014

I want to clone my dotfiles folder (that include the plugins I use) into several remotes where I'm not root, and some of them don't have Python 2.
What I am trying to achieve is a highly portable configuration.
Is there a way of degrading gracefully and start Vim without the error message?

@mengzyou

This comment has been minimized.

Show comment
Hide comment
@mengzyou

mengzyou Jan 15, 2016

I checked my vim verison:

$vi --version | grep python
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace

we can see, have +python/dyn, but it still report this error when I open my vim.

I checked my vim verison:

$vi --version | grep python
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace

we can see, have +python/dyn, but it still report this error when I open my vim.

@den-is

This comment has been minimized.

Show comment
Hide comment
@den-is

den-is Feb 22, 2016

Same here
very same output as comment above
Running Fedora 23

den-is commented Feb 22, 2016

Same here
very same output as comment above
Running Fedora 23

@esphen

This comment has been minimized.

Show comment
Hide comment
@esphen

esphen Mar 3, 2016

Same as den-is and mengzdsd, +python/dyn in vim --version, yet it complains about python 2.x not available. Also Fedora 23

esphen commented Mar 3, 2016

Same as den-is and mengzdsd, +python/dyn in vim --version, yet it complains about python 2.x not available. Also Fedora 23

@Valloric

This comment has been minimized.

Show comment
Hide comment
@Valloric

Valloric Mar 3, 2016

Owner

@esphen What's the output of :echo has('python') for you? My guess is it's 0 because python/dyn means python is loaded dynamically once it's used. YCM checks for python support existing instead of using it and hoping for the best.

Owner

Valloric commented Mar 3, 2016

@esphen What's the output of :echo has('python') for you? My guess is it's 0 because python/dyn means python is loaded dynamically once it's used. YCM checks for python support existing instead of using it and hoping for the best.

@esphen

This comment has been minimized.

Show comment
Hide comment
@esphen

esphen Mar 3, 2016

@Valloric Correct, it is 0, Also, echo has('python3') gives me 1. Thanks for the plug on what python/dyn means. Since vim on Fedora is compiled with this, does this mean I can get vim to detect python2 using some config?

esphen commented Mar 3, 2016

@Valloric Correct, it is 0, Also, echo has('python3') gives me 1. Thanks for the plug on what python/dyn means. Since vim on Fedora is compiled with this, does this mean I can get vim to detect python2 using some config?

@Valloric

This comment has been minimized.

Show comment
Hide comment
@Valloric

Valloric Mar 3, 2016

Owner

@esphen If you get 1 for echo has('python3'), you're golden as soon as #2016 lands, which should be any day now. :)

In fact, we'd love it if you could give that branch a spin and report back on that thread.

Owner

Valloric commented Mar 3, 2016

@esphen If you get 1 for echo has('python3'), you're golden as soon as #2016 lands, which should be any day now. :)

In fact, we'd love it if you could give that branch a spin and report back on that thread.

@TamaHobbit

This comment has been minimized.

Show comment
Hide comment
@TamaHobbit

TamaHobbit Jun 5, 2016

This issue is closed but there's no answer here saying how to fix the problem, which is when python is present on the system, but not in vim.

This issue is closed but there's no answer here saying how to fix the problem, which is when python is present on the system, but not in vim.

@vheon

This comment has been minimized.

Show comment
Hide comment
@vheon

vheon Jun 5, 2016

Collaborator

This issue is closed but there's no answer here saying how to fix the problem, which is when python is present on the system, but not in vim.

Well, you either get an updated vim with the python bindings compiled in (not knowing on which platform you are is difficult to help you), or you compile your own vim.

Collaborator

vheon commented Jun 5, 2016

This issue is closed but there's no answer here saying how to fix the problem, which is when python is present on the system, but not in vim.

Well, you either get an updated vim with the python bindings compiled in (not knowing on which platform you are is difficult to help you), or you compile your own vim.

@j127

This comment has been minimized.

Show comment
Hide comment
@j127

j127 Apr 1, 2017

This is a regular problem with Ubuntu 16.04, because the default Vim only uses Python 3. Some documentation on that for Ubuntu users would be helpful in this section. I haven't solved the problem yet, so I don't know how to fix it.

Basically, you can't run YouCompleteMe on the latest stable Ubuntu without some unknown workaround. I have trouble believing that every Ubuntu 16.04 user is compiling Vim from scratch.

To reproduce, install Ubuntu 16.04 LTS in a virtual machine (or via a live thumb drive), and try to get YouCompleteMe working.

j127 commented Apr 1, 2017

This is a regular problem with Ubuntu 16.04, because the default Vim only uses Python 3. Some documentation on that for Ubuntu users would be helpful in this section. I haven't solved the problem yet, so I don't know how to fix it.

Basically, you can't run YouCompleteMe on the latest stable Ubuntu without some unknown workaround. I have trouble believing that every Ubuntu 16.04 user is compiling Vim from scratch.

To reproduce, install Ubuntu 16.04 LTS in a virtual machine (or via a live thumb drive), and try to get YouCompleteMe working.

@vheon

This comment has been minimized.

Show comment
Hide comment
@vheon

vheon Apr 1, 2017

Collaborator

because the default Vim only uses Python 3

And why is that a problem? YCM works fine with Python 3.

Collaborator

vheon commented Apr 1, 2017

because the default Vim only uses Python 3

And why is that a problem? YCM works fine with Python 3.

@j127

This comment has been minimized.

Show comment
Hide comment
@j127

j127 Apr 2, 2017

And why is that a problem? YCM works fine with Python 3.

Because Ubuntu 16.04 uses Python 2 to compile YCM by default (despite compiling Vim with Python 3 only), which doesn't work. One can't do ./install.py --all. It requres python3 install.py --all. Following the install instructions doesn't work. I will make a pull request in the docs for the Linux section.

j127 commented Apr 2, 2017

And why is that a problem? YCM works fine with Python 3.

Because Ubuntu 16.04 uses Python 2 to compile YCM by default (despite compiling Vim with Python 3 only), which doesn't work. One can't do ./install.py --all. It requres python3 install.py --all. Following the install instructions doesn't work. I will make a pull request in the docs for the Linux section.

homu added a commit that referenced this issue Apr 2, 2017

Auto merge of #2598 - micbou:python-interpreter-no-cache, r=puremourning
[READY] Do not cache Python interpreter path

Once YCM is installed through a plugin manager in Vim (e.g. using the `:PluginInstall` command with Vundle), it picks a Python interpreter (most likely the one used to run YCM inside Vim), caches it, and starts the server with it. This fails since the `ycm_core` library is not yet compiled and the following message is displayed on the status line:
```
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library not detected; you need to compile YCM before using it. Follow the instructions in the documentation.
```
After reading the documentation, the user may then build the library directly from Vim:
```
:!/path/to/YCM/install.py
```
or by opening a new terminal and calling the `install.py` script without leaving Vim. Once the compilation is done, he will restart the server with the `:YcmRestartServer` command. However, since the Python interpreter used to start the server is already cached, YCM will not pick the one from the `PYTHON_USED_DURING_BUILDING` file generated by the `install.py` script. If these Pythons are different (e.g. Python 2 versus Python 3), YCM will fail to start the server again. This doesn't happen if we don't cache the Python interpreter path.

I suspect this is the issue experienced in #2431 and often reported by users on Ubuntu 16.04 where Vim is compiled with Python 3 support but default Python is Python 2. See #2140 (comment) and #35 (comment).

Fixes #2431.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2598)
<!-- Reviewable:end -->
@micbou

This comment has been minimized.

Show comment
Hide comment
@micbou

micbou Apr 2, 2017

Collaborator

@j127 Could you try again with the latest version of YCM?

Collaborator

micbou commented Apr 2, 2017

@j127 Could you try again with the latest version of YCM?

@j127

This comment has been minimized.

Show comment
Hide comment
@j127

j127 Apr 4, 2017

@micbou -- thanks, it works with the version of YCM that I had, but I needed to do $ python3 install.py instead of $ ./install.py. If you made a change that will get it working with just $ ./install.py, then I could uninstall and reinstall to test it (if that would help).

j127 commented Apr 4, 2017

@micbou -- thanks, it works with the version of YCM that I had, but I needed to do $ python3 install.py instead of $ ./install.py. If you made a change that will get it working with just $ ./install.py, then I could uninstall and reinstall to test it (if that would help).

@j127

This comment has been minimized.

Show comment
Hide comment
@j127

j127 Apr 4, 2017

I just reinstalled YCM using only $ ./install.py <languages> and it worked. Thanks!

j127 commented Apr 4, 2017

I just reinstalled YCM using only $ ./install.py <languages> and it worked. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment