0

I'm trying to setup deoplete for Vim in mac os. One requirement for this is to install pynvim which I did with pip3 install pynvim

Now within Vim, :python3 import pynvim throws an error ImportError: No module named pynvim. However, outside Vim, pip3 list lists the package pynvim. I don't understand what is going wrong here.

I have collected some information based on which I think I should be able to get some help to prevent this error.

  • From Vim, :echo exepath('python3') returns /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
  • From Vim, python3 help('modules') doesn't list the package pynvim. Interesting thing here is that python3 help('modules') also shows a warning /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discou raged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first. From this warning, we can see the Vim environment is using python3.8 and not python3.6 which conflicts with what was returned from echo exepath('python3')
  • pip3 -V returns pip 20.2.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip (python 3.6)
  • ls -l /usr/local/bin/python* shows
/usr/local/bin/python -> /usr/local/bin/python3.6
/usr/local/bin/python3 -> ../Cellar/python@3.8/3.8.5/bin/python3
/usr/local/bin/python3-config -> ../Cellar/python@3.8/3.8.5/bin/python3-config
/usr/local/bin/python3.6 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
/usr/local/bin/python3.6-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-config
/usr/local/bin/python3.6m -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m
/usr/local/bin/python3.6m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6m-config
/usr/local/bin/python3.8 -> ../Cellar/python@3.8/3.8.5/bin/python3.8
/usr/local/bin/python3.8-config -> ../Cellar/python@3.8/3.8.5/bin/python3.8-config

Looks multiple Python version on my mac has messed up things. How do I get rid of this mess and prevent the Vim error?

1
  • If you use "dynamic loading" you should be able to set pythonthreedll and/or pythonthreehome; I'm not entirely sure how this works, especially on macOS, so can't give a more comprehensive answer. See :help python-dynamic for some details which should hopefully point you in the right direction. – Martin Tournoij Aug 10 '20 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.