I've followed these instructions, in order to install YouCompleteMe in Vim, but when I issue:
./install.py --clang-completer
The following error message comes up:
Searching Python 2.7 libraries...
ERROR: found static Python library (/usr/local/lib/python2.7/config/libpython2.7.a) but a dynamic one is required. You must use a Python compiled with the --enable-shared flag. If using pyenv, you need to run the command:
export PYTHON_CONFIGURE_OPTS="--enable-shared"
before installing a Python version.
Traceback (most recent call last):
File "./install.py", line 44, in <module>
Main()
File "./install.py", line 33, in Main
subprocess.check_call( [ python_binary, build_file ] + sys.argv[1:] )
File "/usr/local/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/bin/python', u'/home/anmol/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py', '--clang-completer']' returned non-zero exit status 1
and now I'm stuck, what should I do?
You need to compile Vim yourself or get a prebuilt Vim package that was compiled with Python support. If you're on a Debian based system, the easiest way is to download the vim-gnome or vim-gtk package from apt(apt install vim-gtkfor instance). Other distros might have a similar package with python support built in.
Simplest way for a clean uninstall/install of vim with python support 25 Vim 8.0 Python support 0 Installing clang_complete Errors Related 1 How do I enable profile in vim? 5 Compiling vim from source just enabling clipboard 1 Enabling or installing blowfish2 capabilities on VIM 7.4.52 22 How can I install 64-bit Vim on Windows? 13
It seems that, these days, vim-gtk installs Python 3 (as one would hope!). I was confused when :echo has('python')was still returning 0, until I realised :echo has('python3')returned 1.
They might want to compile vim as well, especially if you want code-completion. Here is the configure command: Modified configure command for anaconda:
I checked YouCompleteMe's build system and it uses a custom build script that uses the Python module distutils
to find the paths to Python's library and include directories. Your /usr/local/
installation of Python is probably included in your PATH
variable before the official /usr
installation so just running python
probably runs your custom installation, making distutils
return its directories.
To check whether this is true, try running which python
. I assume it will return something like /usr/local/bin/python
.
At this point, I see several options (in order of preference).
Try running YCM's install script by specifying which Python executable should run it explicitly: /usr/bin/python ./install.py --clang-completer
If you use any additional completers with YCM, you should add the appropriate flags to the above line (e.g. --js-completer
for JavaScript completion).
Edit the script third_party/ycmd/build.py
in YouCompleteMe's plugin directory to hardcode the paths for your custom Python installation. For instance, you could replace the existing FindPythonLibraries
function with the following:
def FindPythonLibraries():
return ('/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so',
'/usr/include/python2.7')
Note that this will make it harder to update YouCompleteMe since you'll have to ensure it doesn't get overwritten when you update its source.
dpkg -S /usr/local/lib/python2.7/config/libpython2.7.a
. This command will tell you which package installed that file, unless you installed it manually (bypassing the package manager)./usr/local
Python installation while ensuring you have a Python from the official repositories installed (packages python2.7
and libpython2.7
).In the long run, you would probably be better off by using the official Python packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With