When I launch NeoVim while a virtualenv is activated, I get the following error:
Error detected while processing function provider#python3#Call:
line   18:
Error invoking 'python_execute' on channel 3 (python3-script-host):
Traceback (most recent call last):
  File "<string>", line 6, in <module>
NameError: name 'execfile' is not defined
Press ENTER or type command to continue
This is what I see when I run :checkhealth provider:
health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy
## Python 2 provider (optional)
  - INFO: pyenv: Path: /usr/local/Cellar/pyenv/1.2.16/libexec/pyenv
  - INFO: pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
  - INFO: pyenv: Root: /Users/myname/.pyenv
  - INFO: Using: g:python_host_prog = "~/.pyenv/versions/2.7.16/envs/neovim-python2-venv/bin/python"
  - INFO: $VIRTUAL_ENV matches executable
  - INFO: Executable: /Users/myname/.pyenv/versions/2.7.16/envs/neovim-python2-venv/bin/python
  - INFO: Python version: 2.7.16
  - INFO: pynvim version: 0.4.1
  - OK: Latest pynvim is installed.
## Python 3 provider (optional)
  - INFO: pyenv: Path: /usr/local/Cellar/pyenv/1.2.16/libexec/pyenv
  - INFO: pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
  - INFO: pyenv: Root: /Users/myname/.pyenv
  - INFO: Using: g:python3_host_prog = "~/.virtualenvs/neovim-python3-venv/bin/python3"
  - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results.
    - ADVICE:
      - If you are using Zsh, see: http://vi.stackexchange.com/a/7654
  - INFO: Executable: /Users/myname/.virtualenvs/neovim-python3-venv/bin/python3
  - INFO: Python version: 3.8.0
  - INFO: pynvim version: 0.4.1
  - OK: Latest pynvim is installed.
I don't use Zsh, I use Bash. An attempt to use the snippet from the linked answer in .bashrc did not change the situation.
I do not get the error when not launching NeoVim while a virtualenv is activated.
Removing all Vim plugins did not get rid of the error.
I have tried this with virtualenvs that use both Python 2 and Python 3. The error is the same.
 
     
     
    