How to get my Vim and MacVim to find python3?
Question:
When I use a plugin that requires python, it can’t find it and barfs.
The places that seem to being searched are:
Using -version
I see both:
+python/dyn
+python3/dyn
However :echo has("python3")
returns 0
.
I’m not sure if this is compile time config, or runtime-configurable via .vimrc
.
I’m not a python developer, and the few times I’ve ventured into that world were in the middle of the python2/python3 mess that turned me off completely. I’ve played around enough to have configured pyenv
it seems, and get
╰─$ which python
/Users/benlieb/.pyenv/shims/python
╰─$ python --version
Python 3.10.3
Can anyone help shed light on what to do to get python3 findable/usable in my vim?
Update:
Following @romainl’s suggestion below I set in my .vimrc
set pythonthreedll=/Users/benlieb/.pyenv/shims/python
But getting the following error:
Answers:
+python/dyn
and +python3/dyn
are described here: :help python-dynamic
.
By default, :help 'pythonthreedll'
points to:
/opt/homebrew/Frameworks/Python.framework/Versions/3.10/Python
because MacVim is built against that version. The message in your screenshot says that there is nothing at that path. In order to have a working Python 3 interface, you can either:
- install Python 3.10 via homebrew,
- or point
pythonthreedll
to a valid path.
For example, I don’t use Homebrew so the default value is useless to me, but I use MacPorts so this is my pythonthreedll
:
set pythonthreedll=/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib
After some time, I found the following works, thought it was not a fun path of discovery.
let &pythonthreedll = trim(system("pyenv which python"))
When I use a plugin that requires python, it can’t find it and barfs.
The places that seem to being searched are:
Using -version
I see both:
+python/dyn
+python3/dyn
However :echo has("python3")
returns 0
.
I’m not sure if this is compile time config, or runtime-configurable via .vimrc
.
I’m not a python developer, and the few times I’ve ventured into that world were in the middle of the python2/python3 mess that turned me off completely. I’ve played around enough to have configured pyenv
it seems, and get
╰─$ which python
/Users/benlieb/.pyenv/shims/python
╰─$ python --version
Python 3.10.3
Can anyone help shed light on what to do to get python3 findable/usable in my vim?
Update:
Following @romainl’s suggestion below I set in my .vimrc
set pythonthreedll=/Users/benlieb/.pyenv/shims/python
But getting the following error:
+python/dyn
and +python3/dyn
are described here: :help python-dynamic
.
By default, :help 'pythonthreedll'
points to:
/opt/homebrew/Frameworks/Python.framework/Versions/3.10/Python
because MacVim is built against that version. The message in your screenshot says that there is nothing at that path. In order to have a working Python 3 interface, you can either:
- install Python 3.10 via homebrew,
- or point
pythonthreedll
to a valid path.
For example, I don’t use Homebrew so the default value is useless to me, but I use MacPorts so this is my pythonthreedll
:
set pythonthreedll=/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib
After some time, I found the following works, thought it was not a fun path of discovery.
let &pythonthreedll = trim(system("pyenv which python"))