Youcompleteme: [Question] How to build YCM with python3 in macOS?

Created on 18 Oct 2017  路  7Comments  路  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][cont] document.
  • [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
  • [x] I have read and understood YCM's [README][readme], especially the
    [Frequently Asked Questions][faq] 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.][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, including what I expected to happen and what actually happened.
  • [x] If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • [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 only use archlinux and macOS, so I don't know how other linux distributions make python2 python3 exist together.

In archlinux, user install python package will add python and python3 to /usr/bin, install python2 package will only add python2 to /usr/bin. So, in fact, I always use python3 to compile YCM.

In macOS, most users use homebrew as package manager. user install python will add python2 to /usr/local/bin, install python3 will add python3 to /usr/local/bin.

I have read install.py script, and it use bash shebang. So #!/usr/bin/env python in macOS will always call the system python which I do not want to use.

Maybe use pyenv as python version manager will solve this problem, so is there some suggestions or instructions can help me?

Most helpful comment

You can always run python3 install.py instead of ./install.py.

All 7 comments

Create symbol link python -> /usr/local/bin/python3 will work, but i think this is not compatible with macOS system python which also provide python in $PATH.

You can always run python3 install.py instead of ./install.py.

I use pyenv but Boris is right too. This applies to all supported platforms.

I think it is answered so closing.

For those that go down the rabbit hole of deciding hey yeah I should use pyenv too, here are instructions.

  1. brew install pyenv
  2. Make sure to read the README in the pyenv repo. This includes adding to your .bash_profile the pyenv init script.
  3. Once done, run pyenv install $VERSION where $VERSION is the version you want.

If you happen to run into something like this when installing python3+

Downloading Python-3.6.5.tar.xz...
-> https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Installing Python-3.6.5...
python-build: use readline from homebrew

BUILD FAILED (OS X 10.13.4 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/02/5gx3m36s321c68bwcq_p1lnm0000gp/T/python-build.20180622105052.49531
Results logged to /var/folders/02/5gx3m36s321c68bwcq_p1lnm0000gp/T/python-build.20180622105052.49531.log

Last 10 log lines:
  File "/private/var/folders/02/5gx3m36s321c68bwcq_p1lnm0000gp/T/python-build.20180622105052.49531/Python-3.6.5/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/private/var/folders/02/5gx3m36s321c68bwcq_p1lnm0000gp/T/python-build.20180622105052.49531/Python-3.6.5/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/02/5gx3m36s321c68bwcq_p1lnm0000gp/T/python-build.20180622105052.49531/Python-3.6.5/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/02/5gx3m36s321c68bwcq_p1lnm0000gp/T/python-build.20180622105052.49531/Python-3.6.5/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

Try running xcode-select --install in your CLI as mentioned in this issue.

@meritozh
Create symbol link python -> /usr/local/bin/python3 will work, but i think this is not compatible with macOS system python which also provide python in $PATH.

maybe you could configure
let g:ycm_server_python_interpreter='/usr/local/bin/python3'
in you vimrc

Create symbol link python -> /usr/local/bin/python3

This is extraordinarily dangerous advice that might cause people to break their system Python :confused:

Don't listen to, appropriately named, extraordinarily dangerous advice and instead listen to what I and and puremourning said.
For further questions, contact us on gitter.

Was this page helpful?
0 / 5 - 0 ratings