I have to get into some python programs so I thought I'd edit my Vim workflow so that Python is optimally efficient too.

I have quite some packages (vim airline, vim ale, ...), a virtual environment for python where the necessary packages are downloaded and Vim has python3 feature enabled (python feature not though but I think that is fine?).

However, when I import packages such as yfinance in my pythonscript.py at the top using import yfinance as yf, I get an error saying that " Unable to import 'yfinance'.

If I run the python script from the terminal using python3 pythonscript.py, everything is fine since the packages are installed there, but they don't seem to transfer to Vim.

Is there some setting that I have to enable for my packages to be carried over to Vim too?

  • 1
    How do you run your script into Vim? Which Vim command do you use? Commented Oct 19, 2023 at 22:18
  • 1
    Hi @Vivian, :echo g:python3_host_prof gives back an undefined variable error. And @Friedrich, I didn't know that! Everywhere I read that the python3 feature has to be enabled so I thought it was important... Commented Oct 20, 2023 at 12:09
  • 1
    Good point, thanks @Friedrich. You solved my issue! Commented Oct 20, 2023 at 12:13
  • 1
    @Airbornedawn345 it the solution address your problem maybe could you accept it using the v button next to the arrow voting buttons. It allow the question to rest :-) Commented Oct 20, 2023 at 14:31
  • 1
    Oh, I think I already did that? Big green check mark is next to the question? Commented Oct 20, 2023 at 16:58

1 Answer 1


The "error" you see is probably virtual text written by ALE and caused by one of the static code checkers run by it. Turning ALE off with :ALEDisable should make the errors disappear.

One of the linters is unaware of the virtual environment you're in and does not find its packages.

Reading through :ALEInfo will show which linters are run and their errors.

I've seen these caused by pylint but I can't tell if it's the same for you.

A quick and dirty solution is to add your virtual environment's site-packages directory to PYTHONPATH e.g. like this:

export PYTHONPATH=$(echo $VIRTUAL_ENV/lib/python*/site-packages):$PYTHONPATH
vim mypythonfile.py

There's a question on SO pylint doesn't point to virutalenv python which seems related. One of the answers there suggest to install pylint in the virtual environment to solve the issue.

In your question, you mention the python and python3 features that show in :version. These say whether Vim itself is able to interpret Python 2.7 or Python 3.x code, respectively. You can write code in any language (natural or programming) without those features.

  • 1
    I was able to solve it by pip installing pylint in my virtual environment. I didn't expect ALE to be the problem. Thank you very much! Commented Oct 20, 2023 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.