I (very) often write python, and I use Vim's python3 backend to test my code. To perform my tests I use:
vnoremap <localleader>p y:<c-r>"<c-b>python3 <cr>
It simply takes my visual selection and runs within Vim's python backend. This is very practical because I can re-run only pieces of code (and I'm careful to remember the state the repl is in).
This works fine even with installed libraries, for example
:python3 import bs4
But my issue starts when I try loading libraries that are not fully written in python. For example trying
:python3 import numpy
I get an error from the backend:
Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/grochmal/.local/lib/python3.5/site-packages/numpy/__init__.py", line 180, in <module> from . import add_newdocs File "/home/grochmal/.local/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/home/grochmal/.local/lib/python3.5/site-packages/numpy/lib/__init__.py", line 8, in <module> from .type_check import * File "/home/grochmal/.local/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/home/grochmal/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 14, in <module> from . import multiarray ImportError: /home/grochmal/.local/lib/python3.5/site-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so: undefine d symbol: PyType_GenericNew
After debugging it a good deal I got to the conclusion that the issue only happens in
/home/grochmal/.local and only to libraries that have components compiled from C. In other words, if I install
/usr/lib it works.
The python REPL has no issue with libraries at
~/.local but Vim's python backend does. I tried with and without:
And the issue persists. Is there a way to use locally installed shared libraries together with Vim's python backend? i.e. Can I tell Vim's python backend to search both places (
~/.local) for symbols to load?
Extra note: both
numpy are in
~/.local in the tests above. In other words libraries that are fully written in python do work in