Reputation: 21453
When I try to open certain python files in neovim, I get an error:
"pool.py" 667L, 25276C
function provider#python#Call[9]..remote#host#Require[10]..provider#pythonx#Require, line 15
Vim(if):ch 1 was closed by the client
Traceback (most recent call last):
File "/home/user/.pyenv/versions/neovim2/lib/python2.7/site.py", line 67, in <module>
import os
File "./os.py", line 44, in <module>
from __future__ import absolute_import
ImportError: No module named __future__
Failed to load python host. You can try to see what happened by starting nvim with $NVIM_PYTHON_LOG_FILE set and opening the generated log file. Also
, the host stderr is available in messages.
Press ENTER or type command to continue
This happens any time I open a python file in a directory that contains an os.py
or os.pyc
file. It looks like neovim is trying to import the local os.py file instead of the one in the virtualenv.
What can I do about this?
EDIT: turns out it's not when I open a file in the same directory as an os.py
file, it's when I open a file anywhere while the current working directory has an os.py
file. Basically, it looks like python is checking the local directory for imports before checking the python libs.
Upvotes: 1
Views: 1089
Reputation: 21453
I figured it out. The problem was with my $PYTHONPATH
. I had in my .bashrc
file this:
export PYTHONPATH="$PYTHONPATH:~/.local/lib/python"
The problem was that, when that line is executed, $PYTHONPATH
is empty, leading to the string starting with a :
. I'm not 100% sure why, but that resulted in python checking the local directory for a module BEFORE checking the python libraries.
I changed it to
if [ -z "$PYTHONPATH" ]; then
export PYTHONPATH="~/.local/lib/python"
else
export PYTHONPATH="$PYTHONPATH:~/.local/lib/python"
fi
And now it works.
Upvotes: 1