Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:
vim --version.:YcmDebugInfo.:YcmToggleLogs command.install.py (or cmake/make/ninja) including its invocationThank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.
I received this message in the bottom when I opened the VIM.
questions: YouCompleteMe unavailable:cannot import name _remove_dead_weakref
Include steps to reproduce here.
Include description of a minimal test case, including any actual code required
to reproduce the issue.
Include description of the expected behaviour.
Include description of the observed behaviour, including actual output,
screenshots, etc.
vim --versionvim --version VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 25 2018 17:23:52)
YcmDebugInfoE492: Not an editor's command
Include link here to a gist containing the entire logfiles for ycm, ycmd
and any completer logfiles listed by:YcmToggleLogs.
ubuntu 16.04
install.py
What's the problem with the Issue?
If :YcmToggleLogs returned Not an editor command it probably means YCM has not loaded at all.
You can check that with :scriptnames.
For anything more specific, please fill out the issue template.
I run the command with :scriptnames in my vim and found the result,
~/.vim/bundle/YouCompleteMe/autoload/youcompleteme.vim
Can you paste the output of :messages?
@micbou The result of the :messages is
Traceback (most recent call last):
File "<string>", line 19, in <module>
File "/home/xw/.vim/bundle/YouCompleteMe/autoload/../python/ycm/setup.py", lin
e 37, in SetUpSystemPaths
from ycmd import server_utils as su
File "/home/xw/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycm
d/server_utils.py", line 26, in <module>
import logging
File "/home/xw/anaconda2/lib/python2.7/logging/__init__.py", line 26, in <modu
le>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File "/home/xw/anaconda2/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Do you get the error if you run the command
python -c "import weakref"
in a terminal?
@micbou weakref can be imported.
And what happens if you do
:py import weakref
in Vim?
@micbou the command was run in vim and the message is
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/xw/anaconda2/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
We don’t support anaconda. Can you try with standard python?
@micbou @puremourning Thank you very much for your answer. I know it.
@JoeyBoyi Did you fix the issue by using a different Python?
@micbou I haven't tried this method lately.I will solve this issue when I am free.
I seem to be having the same issue, i've been trying to debug it for a while, don't seem to be getting anywhere.
FYI: I'm using standard python in my setup and it still doesn't seem to be working for me
Looking at similar issues on the web, it seems to be caused by having two versions of the Python standard library installed on the system and the Python loaded in Vim picking the wrong one. You should compare the paths of the Python executable and the weakref module inside Vim:
:py print(sys.executable)
:py import weakref
You may have to replace :py with :py3 if using Python 3. The second command should raise the error with the path to the weakref module. What's the result of these two commands?
So the first command returns:
/usr/local/bin/python
And the second command returns:
```java
Traceback (most recent call last):
File "
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Could you now run the command:
/usr/local/bin/python -c "import weakref; print(weakref.__file__)"
in a terminal? If the printed path is not the same as the one shown in the error (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py) then we have the confirmation that the Python loaded in Vim is using the wrong standard library path.
hmm, so its pointing to a file with the same name but a different extension, seems like the bytecode
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.pyc
I'm having the same issue with the same output as @cnolimit. I'm using a virtualenv, and I used the same virtualenv to run install.py for YCM. My understanding is that because the path in the error is the same as the path from the terminal, Vim is probably using the correct standard library path. Is that accurate? Any other ideas as to what's going on?
Thanks for your time btw!
UPDATE: I was also looking at https://github.com/Valloric/YouCompleteMe/issues/2136
If I deactivate the virtualenv and explicitly set the g:ycm_server_python_interpreter to the path of the virtualenv python I was using when I installed it, suddenly it seems to work. If I re-activate that same virtualenv though, I get this error again.
I'm going to try reinstalling using a different python and setting that python to that executable and running with the virtualenv.
UPDATE: I tried reinstalling using a different python, setting that python to that executable, and running with virtualenv. It seems like YCM works fine if I don't use the virtualenv (and use the default python which I used this time to run install.py), but if I use virtualenv it shows this same error (YouCompleteMe unavailable: cannot import name _remove_dead_weakref)
I'm having a similar issue – not exactly the same but some of the symptoms are the same. For example, running
:py print(sys.executable)
:py import weakref
yields
/usr/local/opt/python@2/bin/python2.7
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
but
❯ /usr/local/opt/python@2/bin/python2.7 -c "import weakref; print(weakref.__file__)"
/usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.pyc
When I open vim, I see
YouCompleteMe unavailable: dlopen(/usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
:messages
Messages maintainer: Bram Moolenaar <[email protected]>
Traceback (most recent call last):
File "<string>", line 19, in <module>
File "/Users/tupton/.vim/plugged/YouCompleteMe/autoload/../python/ycm/setup.py", line 37, in SetUpSystemPaths
from ycmd import server_utils as su
File "/Users/tupton/.vim/plugged/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/server_utils.py", line 25, in <module>
import io
File "/usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python@2/2.7.14_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
If this is an entirely separate issue, let me know and I can start a new one and provide more details, but I figured it was at least related enough to ask here first.
I should also note that this seemed to start after homebrew made python the python3 formula and python@2 the python2 formula. I do have python3 installed on my system, but it is not linked or otherwise available anywhere in my PATH.
I had a similar issue when brew updated my python. Re-installing YCM and running brew upgrade macvim solved my issue
My specific issue seems to have been fixed by updating to a later python@2 via Homebrew and re-installing YCM. I'm still not 100% sure why it was broken with the initial python@2 formula.
IIRC I had to use --with-python@2 when brewing macvim recently, having never had to do that before. I'm sure there are good reasons behind the changes, despite them being somewhat, erm, ninja.
After update python@2 by brew, I still have this problem. Did anyone find the solution yet?
Same issue on vim but on neovim it works just fine, python2 upgraded
What issue? If you are having an issue, see CONTRIBUTING.md.
"Me too" doesn't really add anything to the discussion, particularly as the OP here didn't fill out the issue template.
We know that hombrew has changed its default python, which sucks, but i'm sure they have their reasons for that. This will almost certainly cause tons of issues. I had to do some work on my own systems to get things working again (notably, rebuild ycm by running install.py).
However, it would be better to raise an issue, following CONTRIBUTING.md and/or moaning at homebrew.
I don't know if this help. If you are using YCM on mac, you can try to override default vim with
brew install vim -with-override-system-vim
With brew-compiled vim, YCM works normally
I have the same issue, just uninstalls the brewed version of python2 solves it
brew uninstall python@2
Encountered this issue and the comment from @yifeikong fixed my environment. 👍
@XiaohuanIT macOS comes with python 2.7 preinstalled, uninstall the brewed version(python@2) rolls back to macOS's own version of python.
The cannot import name _remove_dead_weakref error can probably be fixed by setting the pythonhome or pythonthreehome options (depending on the version of Python used) to the right Python home in vimrc. Anyway, the issue reported by OP can be reproduced with the command :py import weakref (or :py3 instead of :py) in Vim so it's definitely not an issue with YCM. For people having the same error but unable to reproduce with :py import weakref or :py3 import weakref, feel free to open a new issue.
Well, I had the same issue today.
The solution that use the macvim instead of the system vim is effective for me
Just make an alias in the ~/.bashrc, like this
alias vim="path to your macvim"
@MEGACJH Using macvim is not a solution, it's a workaround.
Anyway, the issue reported by OP can be reproduced with the command :py import weakref (or :py3 instead of :py) in Vim so it's definitely not an issue with YCM.
Solution or not, there's nothing we can do if your Vim installation is broken.
I had the same issue in both of my computers in different occasions, and this was my solution
if you do in your terminal
vim --version
you can see there that is the apple compiled version
you need the Homebrew compiled version for that you need to
run this in your terminal
brew install vim
brew unlink vim && brew link vim
after this step is important to close all your terminal sessions and start the terminal again.
type
vim --version
and you will see something like this
nosleepfilipe:~ filipedias$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 7 2018 03:54:05)
macOS version
Included patches: 1-1800
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_sgr -tag_any_white
+arabic +file_in_path -mouse_sysmouse -tcl
+autocmd +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
....
now you can start your vim normally without the error
@puremourning thanks, your solution works on my mac
FWIW I no longer build macvim with py2. I accept the default py 3 now. It just requires rebuilding ycmd once.
After uninstall the python@2, you need to rebuilding ycmd.
@kaiyulee , I just uninstall the python@2. I no need rebuilding ycmd.
it seems you need to relink your system python to default version
in my system (centos6.6) , i soft link /usr/local/bin/python to python2.7, which should be python2.6.
and then i got this problem
when i fix this, by link /usr/local/bin/python to python2.6, i got it run correctly
besides, my vim has enabled python2.7 support
Using python 2.6 won't work. We have dropped support for it a while ago.
brew uninstall --ignore-dependencies --force python@2
Most helpful comment
I had the same issue in both of my computers in different occasions, and this was my solution
if you do in your terminal
you can see there that is the apple compiled version
you need the Homebrew compiled version for that you need to
run this in your terminal
after this step is important to close all your terminal sessions and start the terminal again.
type
and you will see something like this
now you can start your vim normally without the error