python environment not used anymore
Since last update to Version 8.1.1722 (157) (on macOS 10.14.6) a python call within mvim doesn't use the python version from the environment mvim was started from but uses the system python. (before the update the python version from the environment was used)
- activate a python environment in a directory which has a different python version than the system python
(- may check
python --versionin this directory) - run
mvimin this directory - call vim command
:!python --version
On my computer it returns the version number of the os-python not of the env-python
@AUsernameWhichIsNotTaken Thank you for your issue, it is an actual issue which should be fixed.
Please, fill the issue to vim/vim repository, as MacVim is only GUI for ViM, without modifying underlaying processing.
After you fill an issue there, please, add this issue as a back reference to make sure we track it too.
BTW, I observe this on my computer:
~> which vim
vim: aliased to /Applications/MacVim.app/Contents/MacOS/Vim -g
-> echo $VIRTUAL_ENV
/Users/eirnym/Development/sdk/python/37/ens
~> which python
/Users/eirnym/Development/sdk/python/37/ens/bin/python
~>pip list installed
Package Version
---------- -------
Pillow 6.1.0
pip 19.2.1
setuptools 41.0.1
wheel 0.33.4
xxhash 1.3.0
~> python -c 'import xxhash'
~> vim
In vim I able to run !python -c 'import xxhash and !python3 -c 'import xxhash
But I can't run :py3 import xxhash (no such module)
And YouCompleteMe able to complete using libraries in virtual environment.
The problem seems to be that mvim/vim opens a new shell to run cmd from :!cmd because :!echo $PATH =! :echo $PATH. The later returns the content from the path variable of the shell mvim/vim was started in while the former does not.
How to ensure that $PATH of the shell mvim/vim was started in is used for :!cmd-call?
:terminal is resetting path for an unknown for me reason. I have not set a flag ! in :set guioptions, so the path of virtual environment is preserved if I run !echo $PATH. In either case you should ask this in main ViM repository, as it happening in console ViM as well. (if you run /Applications/MacVim.app/Contents/MacOS/Vim)
I bet when I open a terminal in ViM in any way (with ! set or with :terminal), it opens login shell instead of sub shell, but I'm not sure about this.
Is this still an issue? I haven't reproduced this myself with or without guioption+=l. What OSes are you guys running?
I have 10.15 with MacVim 159 (since 157), with python 3.7. I have no problem with this, but some plugins require to be installed in an environment beforehand. As I've said there's nothing with MacVim-specific changes.
- activate a venv
- install some package into venv which isn't installed into system python (I used
xxhashfor my case) - test it with
$ python -c 'import xxhash' - open vim/MacVim
- execute
:!python -c 'import xxhash' - execute
:py3 import xxhash
the latest line will throw that there's no such module.
It's still the same mvim doesn't use the python from the environment it was started in but the system python.
Mac OS 10.15.1, VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 30 2019 11:57:56) macOS version Included patches: 1-2234
@AUsernameWhichIsNotTaken The problem is in Vim Core, it won't be fixed in MacVim before Vim will fixed this issue inside itself.