Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YouCompleteMe does not work with Anaconda Python #1241

Closed
pluskid opened this issue Nov 9, 2014 · 16 comments
Closed

YouCompleteMe does not work with Anaconda Python #1241

pluskid opened this issue Nov 9, 2014 · 16 comments

Comments

@pluskid
Copy link

pluskid commented Nov 9, 2014

This is just a note for anybody who might be having the same issue.

I have Anaconda Python installed and the PATH is changed so that that is my default python interpreter. YCM cannot work. I just got server shutdown message, there is no debug or log information that I could get. However, after randomly trying to explicitly set the python interpreter of YCM to the system one, it started working again:

let g:ycm_path_to_python_interpreter = '/usr/bin/python'
@Valloric
Copy link
Member

Only the official Python distributions are supported. Thank you for reporting this though; hopefully it will help people searching on Google.

@Valloric Valloric closed this as completed Dec 3, 2014
@glortho
Copy link

glortho commented Jan 20, 2015

This helped me, thank you.

@peterjliu
Copy link

Ah yes, fix works. Thanks.

@hjmjohnson
Copy link

NOTE: When compiling YCM, ensure that 'which python' is pointing to /usr/bin/python as well.

@Puriney
Copy link

Puriney commented Dec 20, 2015

Not working anymore.

Using latest macvim, YMC.

First compile YMC with default python /usr/bin/python (2.7.10), setting the let g:ycm_path_to_python_interpreter = '/usr/bin/python'. MacVim with YCM works.

Second I add anaconda to $PATH. It failed.

@ghost
Copy link

ghost commented Dec 28, 2015

YCM was working for me until I installed anaconda2 (which comes with python). Vim wouldn't load at all (would get Vim: Caught deadly signal ABRT error). I tried the suggestion at the beginning (let g:ycm_path_to_python_interpreter = '/usr/bin/python' in my .vimrc) but it didn't work.

As anaconda adds export PATH="~/anaconda2/bin:$PATH" to .bash_profile in Mac (or to .bashrc in Linux), what worked for me was to delete this line from my .bash_profile and added instead export PATH="/usr/local/bin:$PATH". Your default python version should be now the one installed in usr/local/bin/ and not in ~/anaconda2/bin (you can double check with $ which python).

After this I just compiled YCM again, and it started working again.

@vheon
Copy link
Contributor

vheon commented Dec 28, 2015

I tried the suggestion at the beginning (let g:ycm_path_to_python_interpreter = '/usr/bin/python' in my .vimrc) but it didn't work.

We have to separate the errors:

  • Vim: Caught deadly signal ABRT error: That is vim crashing because we're using a python that is different from the one vim was compiled against.
  • YCM is crashing as soon as it starts: That is ycmd (the YCM server) which is not able to run with whatever version of python you have as default.

Using the g:ycm_path_to_python_interpreter variable is useful only for the second kind of error.

@damca
Copy link

damca commented May 22, 2016

I was able to get ycm to compile with anaconda. Anaconda's libpython3.5m.dylib uses relative paths instead of absolute paths (on OSX). See https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/fUpqjkK5jEI

First make macvim and ycm compile with the anaconda interpreter. Then I used the following:
install_name_tool -change libpython3.5m.dylib /path/to/anaconda3/lib/libpython3.5m.dylib ~/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so

@Yefee
Copy link

Yefee commented Sep 14, 2016

@damca, I use miniconda2, that makes no different with anaconda. But I get errors like this

Traceback (most recent call last):
  File "<string>", line 19, in <module>
Press ENTER or type command to continue
  File "/Users/Yefee/.vim/bundle/YouCompleteMe/autoload/../python/ycm/setup.py", line 37, in SetUpSystemPaths
Press ENTER or type command to continue
    from ycmd import server_utils as su
Press ENTER or type command to continue
  File "/Users/Yefee/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/server_utils.py", line 25, in <module>
Press ENTER or type command to continue
    import io
Press ENTER or type command to continue
  File "/Users/Yefee/miniconda2/lib/python2.7/io.py", line 51, in <module>
Press ENTER or type command to continue
    import _io
Press ENTER or type command to continue
ImportError: dlopen(/Users/Yefee/miniconda2/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Press ENTER or type command to continue
  Referenced from: /Users/Yefee/miniconda2/lib/python2.7/lib-dynload/_io.so
Press ENTER or type command to continue
  Expected in: flat namespace
Press ENTER or type command to continue
 in /Users/Yefee/miniconda2/lib/python2.7/lib-dynload/_io.so
Press ENTER or type command to continue
YouCompleteMe unavailable: dlopen(/Users/Yefee/miniconda2/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /Users/Yefee/miniconda2/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /Users/Yefee/miniconda2/lib/python2.7/lib-dynload/_io.so

The solution does not help. Do you have any suggestions?

@boulund
Copy link

boulund commented Oct 25, 2016

I've had success using YouCompleteMe under the Linux Subsystem in Windows 10 Insider Preview like this:

  1. Add/install YouCompleteMe using Vundle (by adding Plugin 'Valloric/YouCompleteMe' to your ~/.vimrc)
  2. Restart vim and run :PluginInstall, wait for it to complete (takes a while). When it finishes, close vim.
  3. Go to ~/.vim/bundle/YouCompleteMe/
  4. Run install.py from inside the YouCompleteMe directory; it will fail. Remember the Python library and include paths, these paths are required in the next step.
    For me the paths were:
    -DPYTHON_LIBRARY=/home/fredrikb/anaconda3/lib/libpython3.5m.so and
    -DPYTHON_INCLUDE_DIR=/home/fredrikb/anaconda3/include/
  5. Go to ~/.vim/bundle/YouCompleteMe/third_party/ycm/cpp/. If there is a CMakeCache.txt, delete it.
  6. Run: cmake -G "Unix Makefiles" -DPYTHON_LIBRARY=/home/fredrikb/anaconda3/lib/libpython3.5m.so -DPYTHON_INCLUDE_DIR=/home/fredrikb/anaconda3/include/ -DUSE_PYTHON2=OFF, then run make.
  7. Start vim on a *.py file to verify that YouCompleteMe now works.

@Yefee
Copy link

Yefee commented Oct 26, 2016

@boulund

Thanks for your detailed response! It seems my version is not exactly as yours. I can install the plugin, but when I start vim it shows the error message as above.

Thanks!

CF

@Weiming-Hu
Copy link

Python Requests HTTPConnectionPool and Max retries exceeded with url

If you have recently installed Anaconda, and when you start your MacVim and find out that it doesn't work anymore. When you run YcmToggleLogs [log file name] in vim, if you get the above error message, this issue is going to help you a lot. Please read this whole post carefully.

I have encountered this problem yesterday, and I spent a WHOLE DAY searching for the error message, but in vain, until I accidentally tried to search anaconda and YCM. I was lucky, but I would like to build any possible relations between that specific error message I got and YCM to save other poor guys' time, in hope that Google will help them help here well.

Finger crossed.

@nikhilpriyatam
Copy link

nikhilpriyatam commented Oct 9, 2017

Workaround for Anaconda/Miniconda + YouCompleteMe users (Those who are getting server shutdown errors). Here is how I fixed it (Tested on Mac using Macvim and ubuntu 16.06 using vim).

Make sure all the environment variables in ~/,bashrc, ~/.bash_profile, ~/.profile point to the default python in /usr/bin/python and not the anaconda / miniconda versions. Double check by printing echo $PATH [You must NOT find anything with *conda*].

Delete the directory ~/.vim/bundle/YouCompleteMe
Re-install the plugin by adding the following lines to ~/.vimrc - Plugin 'Valloric/YouCompleteMe'
Do a :PluginInstall 'Valloric/YouCompleteMe'

Goto ~/.vim/bundle/YouCompleteMe/ and do python install.py.
Done !! Open any sample python file with vim, code completion should now work.

Change the environment variables PYTHONPATH or PYTHON3_PATH to point to your anaconda/miniconda python in ~/,bashrc, ~/.bash_profile, ~/.profile. The code completion still works.

Thanks

@JohnDoe02
Copy link

An alternative, specify the PATH variable explicitly for vim using an alias, e.g.,
alias vim='PATH=/usr/bin vim'

@k-lyda
Copy link

k-lyda commented Oct 23, 2018

I had the same issue. For me worked even simpler solution. I haven't changed any env variables, etc. I've just run the YCM installer using default python. After this - no longer "server restart" message :)

cd ~/.vim/bundle/YouCompleteMe
/usr/bin/python install.py

@bstaletic
Copy link
Collaborator

@k-lyda Yes, that should work for everyone, as it's just building with the system's python and is what we test, support and claim to work. With that and considering there's an FAQ entry about this, I'll lock this thread.

@ycm-core ycm-core locked as resolved and limited conversation to collaborators Oct 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests