Difficulty with python while installing YouCompleteMe in vim
<p>I've followed <a href="https://github.com/Valloric/YouCompleteMe/tree/ddf18cc6ec3bb0108bb89ac366fd74394815f2c6#ubuntu-linux-x64" rel="nofollow">these instructions</a>, in order to install YouCompleteMe in Vim, but when I issue:</p>

<pre><code>./install.py --clang-completer
</code></pre>

<p>The following error message comes up:</p>

<pre><code>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 &lt;module&gt;
    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
</code></pre>

<p>and now I'm stuck, what should I do?</p>

<p>I checked YouCompleteMe's build system and it uses a custom build script that uses the Python module <code>distutils</code> to find the paths to Python's library and include directories. Your <code>/usr/local/</code> installation of Python is probably included in your <code>PATH</code> variable before the official <code>/usr</code> installation so just running <code>python</code> probably runs your custom installation, making <code>distutils</code> return its directories.</p>

<p>To check whether this is true, try running <code>which python</code>. I assume it will return something like <code>/usr/local/bin/python</code>.</p>

<p>At this point, I see several options.</p>

<ol>
<li>Try running YCM's install script by specifying which Python executable should run it explicitly: <code>/usr/bin/python ./install.py --clang-completer</code></li>
<li><p>Edit the script <code>third_party/ycmd/build.py</code> in YouCompleteMe's plugin directory to hardcode the paths for your custom Python installation. For instance, you could replace the existing <code>FindPythonLibraries</code> function with the following:</p>

<pre class="lang-py prettyprint-override"><code>def FindPythonLibraries():
    return ('/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so',
            '/usr/include/python2.7')
</code></pre>

<p>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.</p></li>
<li>Update your custom installation of Python with one built as a shared library. The details of this will depend on how you installed this Python version in the first place. You can check whether you installed it through a package by using <code>dpkg -S /usr/local/lib/python2.7/config/libpython2.7.a</code>. This command will tell you which package installed that file, unless you installed it manually (bypassing the package manager).</li>
<li>Remove your custom <code>/usr/local</code> Python installation while ensuring you have a Python from the official repositories installed (packages <code>python2.7</code> and <code>libpython2.7</code>).</li>
</ol>

<p>In the long run, you would probably be better off by using the official Python packages.</p>

python linux python-2.7 ubuntu vim