Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Could not find neovim #3

Closed
kepbod opened this issue Mar 10, 2017 · 34 comments
Closed

Could not find neovim #3

kepbod opened this issue Mar 10, 2017 · 34 comments

Comments

@kepbod
Copy link

kepbod commented Mar 10, 2017

I have installed neovim via pip install neovim, and in vim the command :python import neovim has no errors. However, when I opened the vim, it reported that No module named 'neovim'.

@roxma
Copy link
Owner

roxma commented Mar 12, 2017

Sorry for the late reply

Does your vim has('pythonx') or has('python3')?

If so, this plugin will choose pythonx (:help pythonx), or python3, the last option is python (python2)

@kepbod
Copy link
Author

kepbod commented Mar 13, 2017

My vim does not have pythonx or python3, and only has python.

@roxma
Copy link
Owner

roxma commented Mar 14, 2017

If you can't do :python import neovim on vim8, You might need to refer to this:
http://vi.stackexchange.com/questions/6604/how-to-access-a-custom-python-module-inside-vim

@kepbod
Copy link
Author

kepbod commented Mar 14, 2017

I could do :python import neovim without any error. I changed to a new computer, and this time it reported nvim-completion-manager core channel terminated.

@roxma
Copy link
Owner

roxma commented Mar 15, 2017

Use this command to set environment variable and start your nvim/vim8

NVIM_PYTHON_LOG_FILE=nvim.log NVIM_NCM_LOG_LEVEL=DEBUG vim

After you see nvim-completion-manager core channel terminated, check the contents of the log files generated by NCM. Especially the one with cm_core in the log file name.

If there's no log file, then you have to try start NCM manually, and see what's happaning,

  1. If you are using vim-hug-neovim-rpc on vim8, use :echo neovim_rpc#serveraddr() to get the rpc server address. (eg. 127.0.0.1:37744). If you're on neovim, use echo v:servername.
  2. Find the pythonx/cm_start.py inside NCM plugin directory. Then use python3 pythonx/cm_start.py core 127.0.0.1:37744 to start NCM manually.

roxma added a commit to roxma/nvim-completion-manager that referenced this issue Mar 15, 2017
@kepbod
Copy link
Author

kepbod commented Mar 15, 2017

I reinstalled vim with python3 supporting. It works fine now. Thanks for your help!

@kepbod kepbod closed this as completed Mar 15, 2017
@willian
Copy link

willian commented Jun 14, 2017

Hi!
First of all, thanks for the awesome work on this plugin.

I'm having a similar issue... I'm using vim8 and I have the same configuration on my Mac and my ArchLinux machines.

nvim-completion-manager + vim-hug-neovim-rpc works fine on my Mac, but fails on my ArchLinux. Maybe I'm missing some dependency, I really don't know. I tried everything from this and other issues I found, but couldn't make it working.

My vim8 has support for python and python3, and this is the log when I run:

NVIM_PYTHON_LOG_FILE=nvim.log NVIM_NCM_LOG_LEVEL=DEBUG NVIM_NCM_MULTI_THREAD=0 vim
2017-06-14 12:10:05,386 [INFO @ cm_start.py:main:46] 8119 - start_channel for cm_core
2017-06-14 12:10:05,387 [INFO @ cm.py:setup_neovim:150] 8119 - connecting to neovim server: 0
2017-06-14 12:10:05,387 [ERROR @ cm_start.py:main:58] 8119 - Exception when running cm_core: [Errno 2] No such file or directory
Traceback (most recent call last):
  File "/home/willian/.vim/bundle/nvim-completion-manager/pythonx/cm_start.py", line 56, in main
    start_and_run_channel(channel_type, serveraddr, source_name, modulename)
  File "/home/willian/.vim/bundle/nvim-completion-manager/pythonx/cm.py", line 171, in start_and_run_channel
    nvim = setup_neovim(serveraddr)
  File "/home/willian/.vim/bundle/nvim-completion-manager/pythonx/cm.py", line 157, in setup_neovim
    nvim = attach('socket',path=serveraddr)
  File "/usr/lib/python3.6/site-packages/neovim/__init__.py", line 101, in attach
    socket_session(path) if session_type == 'socket' else
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/__init__.py", line 32, in socket_session
    return session('socket', path)
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/__init__.py", line 18, in session
    loop = EventLoop(transport_type, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/event_loop/base.py", line 88, in __init__
    getattr(self, '_connect_{}'.format(transport_type))(*args)
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/event_loop/asyncio.py", line 87, in _connect_socket
    self._loop.run_until_complete(coroutine)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "/usr/lib/python3.6/asyncio/unix_events.py", line 236, in create_unix_connection
    yield from self.sock_connect(sock, path)
  File "/usr/lib/python3.6/asyncio/selector_events.py", line 451, in sock_connect
    return (yield from fut)
  File "/usr/lib/python3.6/asyncio/selector_events.py", line 456, in _sock_connect
    sock.connect(address)
FileNotFoundError: [Errno 2] No such file or directory

And some outpus:

When I open vim

Error detected while processing function cm#_auto_enable_check[6]..cm#enable_for_buffer[3]..neovim_rpc#serveraddr:
line    5:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named neovim_rpc_server
line    6:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'neovim_rpc_server' is not defined
E858: Eval did not return a valid python object
line   11:
E475: Invalid argument:
line   17:
E906: not an open channel
Press ENTER or type command to continue
nvim-completion-manager core channel terminated

:python import neovim

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/neovim/__init__.py", line 11, in <module>
    from .msgpack_rpc import (ErrorResponse, child_session, socket_session,
  File "/usr/lib/python2.7/site-packages/neovim/msgpack_rpc/__init__.py", line 10, in <module>
    from .session import ErrorResponse, Session
  File "/usr/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 7, in <module>
    import greenlet
ImportError: /usr/lib/python2.7/site-packages/greenlet.so: undefined symbol: _Py_ZeroStruct

:pythonx import neovim

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/neovim/__init__.py", line 11, in <module>
    from .msgpack_rpc import (ErrorResponse, child_session, socket_session,
  File "/usr/lib/python2.7/site-packages/neovim/msgpack_rpc/__init__.py", line 10, in <module>
    from .session import ErrorResponse, Session
  File "/usr/lib/python2.7/site-packages/neovim/msgpack_rpc/session.py", line 7, in <module>
    import greenlet
ImportError: /usr/lib/python2.7/site-packages/greenlet.so: undefined symbol: _Py_ZeroStruct

:python3 import neovim works

:pythonx import neovim_rpc_server

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named neovim_rpc_server

:python3 import neovim_rpc_server works!

:echo globpath(&rtp,'pythonx/neovim_rpc_server.py',1)

/home/willian/.vim/bundle/vim-hug-neovim-rpc/pythonx/neovim_rpc_server.py

:echo neovim_rpc#serveraddr()

0

I think that's the problem, it can't get the proper RPC server address.

Any help?

Thank you in advance,

@roxma
Copy link
Owner

roxma commented Jun 14, 2017

@willian

This plugin choose pythonx if has('pythonx'), then python3, then python.

In your case, you need to ensure :pythonx import neovim works. Which implies ensuring :python import neovim should work, judging by the information you provided.

As an alternative, you could try add set pyxversion=3 into your vimrc, since :python3 import neovim works on your system.

@willian
Copy link

willian commented Jun 14, 2017

Thanks, @roxma!
It's working now, I tried set pyxversion=0 which will first use python3 then python2 as fallback, but your suggestion worked like a charm! :)

Thanks, again

@suederade
Copy link

suederade commented Mar 16, 2018

:echo has('python3') and :echo has('pythonx') returns 1 but it still can't import neovim (have the package installed) and still errors on every load.

@Shougo
Copy link
Collaborator

Shougo commented Mar 18, 2018

@stevenmwade pip3 install neovim is needed.

@krak3n
Copy link

krak3n commented Mar 28, 2018

Having a similar issue on Arch, running :pythonx import neovim I got this stack trace:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/neovim/__init__.py", line 11, in <module>
    from .msgpack_rpc import (ErrorResponse, child_session, socket_session,
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/__init__.py", line 10, in <module>
    from .session import ErrorResponse, Session
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/session.py", line 6, in <module>
    import greenlet
ImportError: /usr/lib/python3.6/site-packages/greenlet.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PyExc_ValueError

But running python3 -c 'import neovim' worked fine.

This lead me to this issue over at python-greenlet python-greenlet/greenlet#122 where the recommended solution is to downgrade greenlet to 0.4.10.

After running sudo pip3 install greenlet==0.4.10 vim boots up fine.

Hope this helps anyone else running into this problem 😄

@yinflying
Copy link

yinflying commented Apr 9, 2018

@kepbod It works for me. However, because the default of pythonx is python2: so have to add:

if has('python3')                                                                                                 
   set pyx=3                                                                     
else                                                                            
   set pyx=2                                                                     
endif

to .vimrc

@matarc-zz
Copy link

Hello everyone,
I am on macOS El Capitan with vim8 that has('python3') and has('pythonx') but no python2 support.
I have the same issue but the work around I've read above don't work for me.

This is what happens when I start vim8.

[vim-hug-neovim-rpc] failed executing: pythonx import neovim
[vim-hug-neovim-rpc] Vim(pythonx):/must>not&exist/foo:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

I tried 'set pyxversion=3' in my .vimrc but I still have the same issue.
Here's my .vimrc maybe it will help

set nocompatible              " be iMproved, required
set pyxversion=3
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'zchee/deoplete-go', { 'do': 'make'}
call plug#end()
let g:deoplete#enable_at_startup = 1

Any idea ?

@xrayw
Copy link

xrayw commented Jul 21, 2018

I have same error, @MatarC. 😄

@xrayw
Copy link

xrayw commented Jul 25, 2018

@MatarC Hi, 😄 I upgrade my vim by Homebrew and It's working fine now ! The error may caused by you upgraded your python but don't re-compile your vim!

@roxma roxma mentioned this issue Jul 29, 2018
@matarc-zz
Copy link

@UzimakiNaruto seems to work thanks!

@ghost
Copy link

ghost commented Aug 6, 2018

@krak3n I remember this solution worked for me last time, however, now I'm on Python 3.7 and I can no longer downgrade and install greenlet 0.4.10. Are you having any problems after updating Arch?

@krak3n
Copy link

krak3n commented Aug 6, 2018

@terminalproteus I just ran into this today. I'm running Antergos so I dunno for vanilla Arch but I just pip uninstalled neovim, greenlet and msgpack and installed from the repo's instead and it seems to work.

@ktrade
Copy link

ktrade commented Sep 19, 2018

Just installed pip2 install --user neovim and this work for mi. View: https://robertbasic.com/blog/force-python-version-in-vim/

@Jeansen
Copy link

Jeansen commented Dec 12, 2018

I have the same problem with vim 8.1. I do not know what the culprit is, but I must have happened in the last month or so when I updated my system. I currently run on debian/sid and all the above did not work for me :-(

:echo has('python3') and :echo has('pythonx') both return 1. And I can for instance run :python3 print('hello'). The same is true for :pythonx print('hello').

On the terminal I can do:
/usr/bin/python3 -c 'import neovim; print(neovim.__file__)' which will give me /usr/local/lib/python3.6/dist-packages/neovim/__init__.py.

But If I do the same in vim like: :python3 import neovim I get the error No module named 'neovim'.

So, why can I import neovim from the terminal, but not from within vim?

@Shougo
Copy link
Collaborator

Shougo commented Dec 12, 2018

You should reinstall python neovim package.
Because the package is renamed recently.

@Jeansen
Copy link

Jeansen commented Dec 13, 2018

@Shougo What do you mean? Isn't pip3 install neovim the right command? I already tried uninstalling and installing neovim (even system wide and not only for the user).

@Shougo
Copy link
Collaborator

Shougo commented Dec 13, 2018

If so, you should check what python is used in neovim.
:checkhealth

@Shougo
Copy link
Collaborator

Shougo commented Dec 13, 2018

Oh it is Vim8. I recommend for you to set g:python3_host_prog.
I think other Python is used.

@Jeansen
Copy link

Jeansen commented Dec 13, 2018

No, sorry. does not change a thing ;-(

@Shougo
Copy link
Collaborator

Shougo commented Dec 13, 2018

g:python3_host_prog only affect for vim-hug-neovim-rpc.

You should set pythonthreedll option.

@Shougo
Copy link
Collaborator

Shougo commented Dec 13, 2018

Oh I have found you use Debian sid.
I think Python is updated to Python3.7.

But your neovim module is installed in Python3.6 directory.
Please check your report.

@Jeansen
Copy link

Jeansen commented Dec 13, 2018

@Shougo First of all, thanks for your help. I definitely appreciate it!
If I do python3 --version it gives me: python 3.6.7. And /usr/bin/python3 is symlinked to python3.6.
pip3 --version gives me pip 18.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)

Here's what pip3 list shows, maybe it is of help:

Package            Version    
------------------ -----------
ansicolor          0.2.6      
appdirs            1.4.3      
apt-clone          0.2.1      
asciinema          2.0.1      
asn1crypto         0.24.0     
beautifulsoup4     4.6.3      
bmap-tools         3.5        
Brlapi             0.6.7      
bro-pkg            1.4.2      
btest              0.58       
cached-property    1.5.1      
certifi            2018.4.16  
cffi               1.11.5     
chardet            3.0.4      
chrome-gnome-shell 0.0.0      
Click              7.0        
cryptography       2.4.2      
cson               0.7        
cupshelpers        1.0        
Cython             0.28.4     
debmake            4.3.1      
defer              1.0.6      
devscripts         2.18.10    
distlib            0.2.8      
distro             1.3.0      
docker             3.6.0      
docker-compose     1.23.2     
docker-pycreds     0.4.0      
dockerpty          0.4.1      
docopt             0.6.2      
entrypoints        0.2.3.post3
fail2ban           0.10.2     
galternatives      1.0.2      
gbp                0.9.10+nmu1
gitdb2             2.0.5      
GitPython          2.1.11     
gpg                1.12.0     
greenlet           0.4.10     
Guake              3.4.0      
html5lib           1.0.1      
httplib2           0.12.0     
idna               2.6        
iotop              0.6        
jeepney            0.4        
jsonschema         2.6.0      
keyring            17.0.0     
keyrings.alt       3.1        
louis              3.7.0      
lxml               4.2.5      
Mako               1.0.7      
Markdown           3.0.1      
MarkupSafe         1.1.0      
mate-tweak         18.10.2    
meld               3.18.3     
menulibre          2.2.0      
meson              0.49.0     
msgpack            0.5.6      
neovim             0.3.1      
npm2deb            0.2.8      
numpy              1.15.4     
olefile            0.46       
pathspec           0.5.9      
pbr                5.1.1      
pcp                4.1        
pexpect            4.6.0      
Pillow             5.3.0      
pip                18.1       
pipdate            0.2.4      
psutil             5.4.8      
pyasn1             0.4.4      
pybin              0.3.4      
pycairo            1.16.2     
pycparser          2.19       
pycrypto           2.6.1      
pycups             1.9.73     
pycurl             7.43.0.1   
PyGObject          3.30.2     
pyinotify          0.9.6      
pynvim             0.3.1      
PySimpleSOAP       1.16       
pysmbc             1.0.15.6   
python-apt         1.7.0      
python-dateutil    2.7.5      
python-debian      0.1.33     
python-debianbts   2.7.3      
python-magic       0.4.16     
python-pam         1.8.4      
python-xapp        1.2.0      
python-xlib        0.23       
pyxdg              0.25       
PyYAML             3.13       
QtPy               1.5.2      
ranger-fm          1.9.2      
reportbug          7.5.1      
reportlab          3.5.12     
requests           2.18.4     
rubber             1.5.1      
SecretStorage      3.1.0      
semantic-version   2.6.0      
setproctitle       1.1.10     
setuptools         40.1.0     
simple-cdd         0.6.5      
six                1.12.0     
smmap2             2.0.5      
soap2py            1.16       
speg               0.3        
systemd-python     234        
texttable          1.5.0      
ufw                0.35       
unidiff            0.5.5      
urllib3            1.22       
vboxapi            1.0        
vim-vint           0.3.19     
webencodings       0.5.1      
websocket-client   0.54.0     
wheel              0.31.1     
yamllint           1.13.0 

@Shougo
Copy link
Collaborator

Shougo commented Dec 13, 2018

I recommend for you to use neovim instead...

I don't know why it does not work in your environment.
Because it works for me.

I think you should rebuild your Vim to the latest version.

@Shougo
Copy link
Collaborator

Shougo commented Dec 13, 2018

And you should test vim-hug-neovim-rpc in othe environment.
Your problem seems environment specific.

@Jeansen
Copy link

Jeansen commented Dec 14, 2018

Yes, indeed. I went back in history. Up to this one, everything works fine: https://snapshot.debian.org/package/vim/2%3A8.1.0320-1/#vim-gtk3_2:3a:8.1.0320-1

But after that, the problems popped up. I'll contact the maintainer of the package. Thanks for all your help!

@tristanbatchler
Copy link

@Wir3 and to anyone else who is having issues downgrading to greenlet-0.4.10 while on python-3.7, I think it's a bug with cython being incompatible with python-3.7. You'll have to do what I did and first uninstall the current version of greenlet with pip3 uninstall greenlet and reinstall version 0.4.10 manually after making some slight adjustments in the source:

wget https://files.pythonhosted.org/packages/f2/3f/09412b656067f280cf017ce5b6465e6339089129212425111117be5557d9/greenlet-0.4.10.tar.gz
tar xvzf greenlet-0.4.10.tar.gz
cd greenlet-0.4.10/

Before running python setup.py install we need to edit the greenlet.c. Just change exc_type to curexc_type

  • after the equals sign on lines 463, 464, & 465, and
  • before the equals sign on lines 485, 487, & 489.

Finally you can run python setup.py install and everything should work out.

@Jeansen
Copy link

Jeansen commented Jan 2, 2019

I also found, that easy_install can be of help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests