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 unavailable+ Symbol not foun d: __PyCodecInfo_GetIncrementalDecoder #2218

Closed
1 of 11 tasks
zhpmatrix opened this issue Jun 25, 2016 · 38 comments
Closed
1 of 11 tasks

Comments

@zhpmatrix
Copy link

zhpmatrix commented Jun 25, 2016

Issue Prelude

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

  • I have read and understood YCM's CONTRIBUTING document.
  • I have read and understood YCM's CODE_OF_CONDUCT document.
  • I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • 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.
    )
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have included the output of
    :YcmToggleLogs stderr.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • If filing a bug report, I have included a minimal test case that reproduces
    my issue.
  • 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.
  • 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

[If filing a bug report, please include a list of steps that describe how to
reproduce the bug you are experiencing. Also include test code if relevant.]


in my macbook air,I meet this problem,how to solve it?I need your help!3Q!

YouCompleteMe unavailable: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Pyt
hon.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not foun
d: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/V
ersions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib

/python2.7/lib-dynload/_io.so

@puremourning
Copy link
Member

Try rebuilding (re-runing install.py). It seems that the version of libpython that is being found at runtime is not the same as the one linked against at compile time.

In any case, this is an issue with your environment, not a bug, so closing per CONTRIBUTING.md

@zhpmatrix
Copy link
Author

Thanks for your answer! Maybe I need to read CONTRIBUTING document firstly, but I can't wait to solve this problem, because YouCompleteMe is really cool! Good luck to me!

@gabrielhpugliese
Copy link

gabrielhpugliese commented Jun 29, 2016

I have the exactly same problem after fresh install of YCM with Python 2.7.11.
Re-running install.py didn't solve the problem. And it's the same env, same terminal session.

When opening vim:

YouCompleteMe unavailable: dlopen(/usr/local/Cellar/python/2.7.11/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.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

And then I don't have any YCM command on vim to debug.

@samuelrey
Copy link

I encountered the same problem. Couldn't find the file at /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so manually. I tried to reinstall python
brew install python
and got
python-2.7.6 is already installed, it's just not linked

You can force it to link using
brew link --overwrite python

but be sure to check the changes using
brew link --overwrite --dry-run python.

@Jan-zou
Copy link

Jan-zou commented Jul 4, 2016

I have the same problem with OS X EI Captian 10.11.5.
Run install.py successfully, but when opening vim:

YouCompleteMe unavailable: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io
.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Hope someone can tell me the reason.

@F1LT3R
Copy link

F1LT3R commented Sep 14, 2016

+1
Same problem it seems. OSX X 10.11.6.
brew linking does not seem to fix things for me

@F1LT3R
Copy link

F1LT3R commented Sep 14, 2016

Apologies, it works fine with latest MacVim from here: https://github.com/macvim-dev/macvim/releases (as provided in your docs)
Perhaps brew is installing an out of date MacVim for me. ¯_(ツ)_/¯

@tommyjcarpenter
Copy link

I am also having this problem on 10.11.6

@F1LT3R
Copy link

F1LT3R commented Sep 20, 2016

Not sure if this helps anyone but me... I found that I had two versions of MacVim installed.

  1. /Applications/MacVim.app
  2. /usr/local/Cellar/macvim/8.0-110/MacVim.app

When I was running mvim my-file.txt from the command line, I would have no YCM errors. But when running MacVim using open -a MacVim.app my-file.txt I would get YCM errors (I did this so I could open files in the same MacVim window from the CLI).

It appears that open checks /Applications before $PATH, and that my YCM errors disappeared when I use the brew Cellar version of MacVim.app.

@Arieg419
Copy link

Kudos to @F1LT3R 's solution, since it worked for me as well.

I did the following:

  1. http://macvim-dev.github.io/macvim/ (Download the latest binary)
  2. Open the MacVim.dmg file.
  3. Drag it onto Applications, overwriting the MacVim you previously had.

Fixed it for me!

Cheers :)

@oscar-c
Copy link

oscar-c commented Sep 24, 2016

I have the same problem, not with the Home-brew vim of version 8, but with the OSX default vim at /usr/bin/vim of version 7.4, and the result of :py import sys; print(sys.version) is 2.7.10.
I also have Home-brew python installed (version 2.7.12).
However if I do brew unlink python the problem is gone.

@birdyhuang
Copy link

@oscar-c I got the same issue. And your solution unlink python actually solves the problem. Don't know why.

@oscar-c
Copy link

oscar-c commented Sep 25, 2016

I figured out it's about $PATH.
So if I set the $PATH to a way that /usr/bin/ is searched before /usr/local/bin in .vimrc, there will not be such problem either.

This is a wired behavior about vim, when brew python is linked, even if I start vim with parameter -u NONE, for /usr/bin/vim, then run :py import sys; print(sys.executable), its sys.executable will be the the brew's python, where it should really be /usr/bin/python. This causes the sys.path to contain bunch of paths to packages that are compiled for the brew python of version 2.7.12, while the sys.version still says 2.7.10. I guess this is the cause. @birdyhuang

@acrazing
Copy link

acrazing commented Nov 9, 2016

This is because mac system requires python 2.7.10 and you installed python 2.7.12 by brew install python.

The result is:

# install by brew
brew install python

# python path, this will be used when make vim
which python
# output: /usr/local/bin/python

# and its version:
$(which python) --version
# output: Python 2.7.12
# but the real python version:
python --version
# output: Python 2.7.10

And you cannot remove system default python:

sudo rm -f /usr/bin/python
# Password:
# rm: /usr/bin/python: Operation not permitted

And then you may need to re-configure and make vim again. Don't forget to clean previous configure output, because the path of python will be cache.

# The most radical way to clean cache
rm -rf ./*
git co -- .

@benjamincharity
Copy link

@oscar-c's solution worked for me:

So if set the $PATH to a way that /usr/bin/ is searched before /usr/local/bin in .vimrc, there will not be such problem either.

I swapped the order of those two and the error immediately went away.

  • VIM - Vi IMproved 7.4
  • Python 2.7.10

@ay18
Copy link

ay18 commented Feb 18, 2017

@benjamincharity @oscar-c But shouldn't /usr/local/bin be before /usr/bin in your $PATH to give brew's packages precedence? Brew will complain if you run brew doctor otherwise.

@oscar-c
Copy link

oscar-c commented Feb 18, 2017

@sksea that is why I only doing it in the .vimrc file.
Actually I scripted it to first check if the version is below 800. If so, the precedence will be changed. I did this in order to minimize the impact of this change.

@ay18
Copy link

ay18 commented Feb 22, 2017

@oscar-c missed that part, thanks for clarifying

@vitosans
Copy link

Just about gave up on YCM and mac, but found a weird solution that worked for me. I created a virtual python evn and ran ./install.py - this works and YCM works. deactivate and YCM still works, so win / win for me. I can finally enjoy YCM

Hope this helps someone else.

@luguozi
Copy link

luguozi commented Mar 17, 2017

@oscar-c think you very much

@rixth
Copy link

rixth commented Mar 21, 2017

For me, the cause was a different version of @F1LT3R's: ~/.gitconfig had a fully-specified path to the system vim at /usr/bin/vim rather than the one from Homebrew... another thing for people having this issue to check.

@xwind
Copy link

xwind commented May 5, 2017

I have not perfect solution
open your vimrc and append

let $PATH='$HOME/.cargo/bin:/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin'

You can use your compiler installed by brew other than Apple,but it not woks for python itself.

Hope author can solve it or invent a method to run install.py with correct python compiler

@CuriousCat-7
Copy link

@xwind thank you, really elegant way

@faithfracture
Copy link

For me, it seems like either the homebrew cask version MacVim (I use the cask version so it links properly to /Applications. I know there's other ways to do this, but... that's the way I chose to do it) or the homebrew version of vim was interfering with something (or maybe I hadn't installed them properly in the first place). I fixed this by doing

brew uninstall vim
brew cask uninstall maccvim
brew install vim --with-override-system-vi
brew cask install mccvim

After that, YouCompleteMe is working as expected.

@MrJadaml
Copy link

@faithfracture's worked for me, though with the following changes:

brew uninstall vim
brew uninstall macvim
brew install vim --with-override-system-vi
brew install macvim

@miguelmota
Copy link

Running

brew uninstall vim
brew install vim --with-override-system-vi

worked for me

@redwud
Copy link

redwud commented Apr 16, 2018

This works with me though:
brew upgrade vim

@sawyna
Copy link

sawyna commented Jun 8, 2018

This would work in the following two combinations.

  1. Use system python (/usr/bin/python) along with system vi.
  2. If you installed another version of python with brew (/usr/local/bin/python), install vim via brew. Don't forget restarting the shell or doing hash -r python. Otherwise you'll end up in the same mess and vim tends to use python from the cache which is /usr/bin/python.

Detailed steps for those who want to retain brew python

  1. brew install vim --with-python@2 (I am using python2 everywhere. You can choose to omit this if you are onto python3)
  2. For some reason, we need to do brew install cmake. I haven't figured out why.
  3. hash -r python OR restart the shell
  4. Open vim and do :PluginInstall. (Assuming you are using Vundle)
  5. If the issue still persists,
git clone <YouCompleteMe>
cd YouCompleteMe
<python>(This needs to be the brew python) install.py <with any params you want> 

System version of vim doesn't bade well with brew python version.

@feifei435
Copy link

feifei435 commented Aug 25, 2018

I happend install a package which depends on python@2, and this caused an upgrade of python@2 from 2.7.14_2 to 2.7.15_1 , but the origin vim installed by brew install vim depends on python 2.7.14_2, thus caused this error.
The solution is just upgrade the vim by brew upgrade vim too, the newest vim depends on python 2.7.15_1 , which matches the current python version in system.
This is why @miguelmota's and @redwud's solution work.

@bguo068
Copy link

bguo068 commented Aug 26, 2018

It seems that I used brew to upgrade python from 2 to 3 so that something is missing for python2
so install python 2 again

brew install python@2

then the error went way.

@jack-nie
Copy link

jack-nie commented Sep 1, 2018

if you install python3, then uninstall python3
brew uninstall python &&brew unlink python &&brew link python

@lyuwen
Copy link

lyuwen commented Sep 18, 2018

Where is the solution then? I've tried all above and nothing works.

@moseshu
Copy link

moseshu commented Nov 19, 2018

when I use vim open a file. One error happened,
this is the error below. How to fix it? thanks

YouCompleteMe unavailable: dlopen(/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.fr
amework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 0x0002): code signature in (/usr/lo
cal/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dy
nload/_io.so) not valid for use in process: mapped file has no cdhash, completely unsigned
? Code has to be at least ad-hoc signed.

@bstaletic
Copy link
Collaborator

@moseshu I believe your vim installation is broken. Or python installation. #3216

@johannes87
Copy link

I still get the original error:

YouCompleteMe unavailable: dlopen(/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_i
o.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /usr/local/Cellar/python@2/2.7.15_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.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Note: I'm using MacVim from the .dmg file, I copied MacVim.app into /Applications, and my /usr/local/bin/vim uses it. Version 8.1.560, snapshot 152.

When I run brew unlink python@2, it works.

But this doesn't explain why YCM complains when I have homebrew-python first in my PATH.

I tried these two commands, both work:
/usr/local/bin/python -c "import _io"
/usr/local/bin/python -c "import io"

What I found odd is that when homebrew-python is first in PATH, and I run :py print(sys.version) inside VIM, I get 2.7.10, which is the version of my system python (/usr/bin/python).

When I run :py print(sys.executable), I get /usr/local/opt/python@2/bin/python2.7, i.e. homebrew-python

:py print(sys.path) also shows the paths for homebrew-python

Why does print(sys.version) give me the system python? What actually causes this error?

@bstaletic
Copy link
Collaborator

From your vim, does :py import _io work? If it doesn't, it's a problem with your vim/python configuration.

@johannes87
Copy link

Seems to be a recent MacVim regression, see macvim-dev/macvim#803

@joemcmahon
Copy link

I was able to get the binary installed by doing

brew install python@2
cd ~/.vim/bundle/YouCompleteMe
python2 ./install.py --clang-completer

Ensuring the Python that you're running and the Python you invoke when running install.py are the same is the key to success.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
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