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:
Error detected while processing function <SNR>75_TryAllFormatters[56]..<SNR>75_TryFormatterPython3:
line 59:
Traceback (most recent call last):
File "/mingw64/lib/python3.8/subprocess.py", line 64, in <module>
import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/mingw64/lib/python3.8/subprocess.py", line 69, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
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 notifications@github.com
wrote:
Did you even read my comment on #1728
https://github.com/msys2/MSYS2-packages/issues/1728?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/msys2/MSYS2-packages/issues/1930#issuecomment-620365414,
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.
@lazka
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 let g:python3_host_prog=/usr/bin/python3 into .vimrc might help.
I tried this but it's showing this error:
Error detected while processing .vimrc:
line 2:
E15: Invalid expression: /usr/bin/python3
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.
But when I update python to 3.8 and vim to 8.2 592-1, the ycm doesn't work. I got the message:
YouCompleteMe unavailable: No module named '_socket'
So I tried to input the command py3 import socket in vim,
It responsed as the following message:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/mingw64/lib/python3.8/socket.py", line 49, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
How to make ycm work in vim 8.2.0592-1 ?
@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:
export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.8/lib-dynload/
Though there is a chance I might be mixing and matching msys/python with mingw64/mingw-w64-x86_64-python in a weird way since I have them both installed. I may be using one's executable to point to the other's libraries?
I created a small program:
import os, sys, _socket
print(sys.executable)
print(sys.version)
print(_socket.__file__)
[~]$ /mingw64/bin/python socket_location.py
C:/msys64/mingw64/bin/python.exe
3.8.2 (default, Apr 9 2020, 13:17:39) [GCC 9.3.0 64 bit (AMD64)]
C:/msys64/mingw64/lib/python3.8/lib-dynload/_socket-cpython-38.dll
[~]$ /bin/python socket_location.py
/bin/python.exe
3.8.3 (default, May 18 2020, 08:39:23)
[GCC 9.3.0]
/usr/lib/python3.8/lib-dynload/_socket.cpython-38-x86_64-msys.dll
(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 :python3 import os, sys, _socket; print(sys.executable); print(sys.version); print(_socket.__file__);, I get:
/mingw64/bin/python3.exe
3.8.3 (default, May 18 2020, 08:39:23)
[GCC 9.3.0]
/usr/lib/python3.8/lib-dynload/_socket.cpython-38-x86_64-msys.dll
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 export PYTHONPATH=$PYTHONPATH:/mingw64/lib/python3.8/lib-dynload/ (which was the first thing I tried) it did NOT fix the issue. Maybe I'm just not giving it the right path style for mingw program.
Most helpful comment
I installed the plug youcompleteme for vim, it worked well in python 3.7.
But when I update python to 3.8 and vim to 8.2 592-1, the ycm doesn't work. I got the message:
YouCompleteMe unavailable: No module named '_socket'So I tried to input the command
py3 import socketin vim,It responsed as the following message:
Traceback (most recent call last): File "<string>", line 1, in <module> File "/mingw64/lib/python3.8/socket.py", line 49, in <module> import _socket ModuleNotFoundError: No module named '_socket'How to make ycm work in vim 8.2.0592-1 ?