New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python doesn't load libraries when ran from vim #1930
Comments
Did you even read my comment on #1728? |
I need to use the mingw64 prompt. Is there no solution for that?
…On Mon, Apr 27, 2020, 11:55 PM StarWolf3000 ***@***.***> wrote:
Did you even read my comment on #1728
<#1728>?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1930 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABLMCWODAXRPIUVGVEATW3DROZHSBANCNFSM4MSMMAZQ>
.
|
It is not supported and most likely never will. Why do you need to use Python in vim in mingw64 shell?There's nothing that justifies it. You can use it just fine in msys2 shell. Well yeah, you need to open a second instance of mintty (just by running msys2.exe), running in msys2 mode, but that's okay. Vim does not load the Python installed under /usr, when run from a mingw shell, and this results in missing modules it needs to work properly. |
I guess we have to force the vim python support to use the msys one. I don't know much about vim, but the README from your plugin suggests that putting |
I tried this but it's showing this error:
I think this only works for neovim, not vanilla vim. I also tried with quotes around the path, but still receive the same error using Autoformat as before. |
I installed the plug youcompleteme for vim, it worked well in python 3.7. |
@StarWolf3000 The reason for doing this is to run python based vim plugins such as YouCompleteMe (I'm was running into the same issue @Jokia is with this same plugin). @Jokia I was running into the same issue with the same plugin. I was able to resolve the error message by adding the following line to my .bashrc: Though there is a chance I might be mixing and matching I created a small program:
(note the mingw version says 3.8.2 up there, the same version that pacman says for my mingw version) But inside of vim when I run the same program using the vim command
It is saying it is the mingw64 python3 executable (version 3.8.2) but its reporting my msys python version number (version 3.8.3). Not even sure how that is possible, but I guess that is what you get when my paths are pointing to some components of the other version of python. Note when I tried |
Thank for your reply. @anythingapplied I have tried update vim and python to the newest version, and add Now, I'm using the vim from MSYS for programming, and it works well. mingw64/mingw-w64-x86_64-python and msys python are diffrent: conan-io/conan#2638 (comment) |
How does the msys2 A tribal way to reproduce/test this is to install msys2 python and msys2 vim, along with mingw64 python (there is no mingw64 vim afaict):
Then, tell vim to load the msys2 python dll and confirm that "works" in both envs:
You will see in the mingw64 env:
This seems kind of funky. I'm trying to understand how the default sys path is worked out in the mingw64 environment, even when loading msys binaries. I understand the comment about "don't mix mingw64 and msys in the same env", but that can't be a universal rule, as To answer the banal question about why you would "want" to use libpython within Vim in a mingw environment, many Vim plugins, mappings, scripts etc. want to operate within your build envrionment. YCM is an example, so is Vimspector. SO is |
Incidentally, if you open mingw64.exe and do It seems like things (other than /usr/bin/python) loading msys-python3.10.dll are somehow not getting the right sys path, but I'm getting into very hairy "hand wavy" areas of my understanding now. |
This seems to be an issue with either allowing dynamically loading a Python3 interpreter if needed, or with the configure and compilation commands. This problem can be circumvented by prefixing the PATH with the msys2's bin folders before opening vim, which will make it load everything from there if it's available. It's a hackjob workaround, but seems to work just fine on my end without any errors. Errorstack from loading the offending Python-based plugin (UltiSnips in my case): Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/__init__.py", line 6, in <module>
from UltiSnips.snippet_manager import UltiSnips_Manager
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet_manager.py", line 13, in <module>
from UltiSnips import vim_helper
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/vim_helper.py", line 13, in <module>
from UltiSnips.snippet.source.file.common import normalize_file_path
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/__init__.py", line 8, in <module>
from UltiSnips.snippet.source.file.snipmate import SnipMateFileSource
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/source/file/snipmate.py", line 10, in <module>
from UltiSnips.snippet.definition import SnipMateSnippetDefinition
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/definition/__init__.py", line 3, in <module>
from UltiSnips.snippet.definition.ulti_snips import UltiSnipsSnippetDefinition
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/definition/ulti_snips.py", line 6, in <module>
from UltiSnips.snippet.definition.base import SnippetDefinition
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/snippet/definition/base.py", line 16, in <module>
from UltiSnips.text_objects import SnippetInstance
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/text_objects/__init__.py", line 9, in <module>
from UltiSnips.text_objects.shell_code import ShellCode
File "/home/Martin/.vim/plugged/ultisnips/pythonx/UltiSnips/text_objects/shell_code.py", line 8, in <module>
from subprocess import Popen, PIPE
File "/mingw64/lib/python3.11/subprocess.py", line 104, in <module>
from _posixsubprocess import fork_exec as _fork_exec
ModuleNotFoundError: No module named '_posixsubprocess' Looking at the relevant code in /mingw64/lib/python3.11/subprocess/py, it seems to be probing the environment to see if |
Having a similar issue to #1728
Packages
python 3.8.2-1
vim 8.2.0592-1
Using the mingw64 shell, I get this error when trying to use https://github.com/chiel92/vim-autoformat. Modules load just fine from the prompt, but running in vim I get the following:
The text was updated successfully, but these errors were encountered: