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 beautifulsoup4 works::python3 import bs4But my issue starts when I try loading libraries that are not fully written in python.  For example trying numpy::python3 import numpyI 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 multiarrayImportError: /home/grochmal/.local/lib/python3.5/site-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so: undefined symbol: PyType_GenericNewAfter 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 numpy into /usr/lib it works.The questionThe python REPL has no issue with libraries at ~/.local but Vim's python backend does.  I tried with and without:export PYTHONPATH=/home/grochmal/.local/lib/python3.5/site-packagesAnd 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 (/usr/lib and ~/.local) for symbols to load?Extra note: both bs4 and numpy are in ~/.local in the tests above.  In other words libraries that are fully written in python do work in ~/.local
Vim python backend, how to import user installed shared libraries?
vimscript python
This is because your numpy isn't linked against the Python 3 library (no -lpython3 used). This is fine for most applications that has the library loaded into global space, but Vim uses RTLD_LOCAL so numpy's libraries don't see Python 3's symbols unless it's linked against it.LD_PRELOAD is fine as long as you don't load Python 2 in the same Vim (or symbols may clash; that's why Vim doesn't use RTLD_GLOBAL). You can also recompile your numpy with -lpython3 (from Arch's PKGBUILD it seems that export LDFLAGS=-shared is enough to do that).