79817062

Date: 2025-11-11 19:51:47
Score: 0.5
Natty:
Report link

Thanks for your reply. I didn't think my use case was that unusual but I'm beginning to realize that it is. What I'm trying to do is control the python version and sys.path that is utilized by vim. To me, the reason is self evident: the scripts that I'm executing with vim's python module require me to control the python environment (i.e. sys.path). This is exactly why virtual environments exist in the first place.

I typically use gvim for python development and launch vim from a virtual environment. I use Vim's terminal to launch python apps inside of a virtual environment. I also utilize a number of custom python tools that I execute from within vim with: py3, py3eval .. etc.

Vim DOES honor these options:

set pythonthreehome=C:\Python314
set pythonthreedll=C:\Python314\python314.dll

And vim's python sys.path DOES follow with the version of Python, it is also is modified, so for my configuration vim's python sys.path is

c:\python314\python314.zip
c:\python314\dlls
c:\python314\lib
c:\apps\vim\vim91
c:\python314
c:\python314\lib\site-packages
_vim_path_

Evidently, vim is modifying it's python environment to add:

c:\apps\vim\vim91
_vim_path_

My desire is to change this behavior so that vim's sys.path matches the virtual environment that it was launched but also keep the capability to

import vim

I think I now have enough information to write some vimscript to modify the sys.path as I need. Thanks for your help.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (0.5): I need
  • Whitelisted phrase (-0.5): Thanks for your help
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: NW_BlackDog