kevinhwang91 / rnvimr

Make Ranger running in a floating window to communicate with Neovim via RPC
BSD 3-Clause "New" or "Revised" License
805 stars 17 forks source link

using rnvimr with virtualenv #19

Closed romanegloo closed 4 years ago

romanegloo commented 4 years ago

Hi, I have a problem with virtualenv. Ranger works fine with the host environment, but I use Python virtualenvs most of the time. When I am in a virtualenv where pynvim is not installed, ranger fails with the following error message from ~/.config/nvim/plugged/rnvimr/bin/editor.py

No module named "pynvim"

What I've tried is to create another virtualenv for neovim3 in which I installed all the required modules and add the interpreter path to it as below.

let g:python3_host_prog = '/Users/jihonoh/.pyenv/neovim3/bin/python'

Still, it's not working. Any ideas?

kevinhwang91 commented 4 years ago

Sorry for my late reply. Does it only occur by Enter or l? Have you tried <C-t> or <C-v> or <C-x>?

kevinhwang91 commented 4 years ago

Please update the code of master branch, I think this bug has gone.

romanegloo commented 4 years ago

Thanks a lot. You solved the issue like a charm.

bangarangler commented 4 years ago

sitll getting the above issue also have conflicts with pyenv.

if has('nvim') let g:python3_host_prog = '/Users/pathHere/.pyenv/versions/neovim3/bin/python' let g:python_host_prog = '/Users/pathHere/.pyenv/versions/neovim2/bin/python' endif

is there another step I am missing?

Thanks all ; )

kevinhwang91 commented 4 years ago

sitll getting the above issue also have conflicts with pyenv.

if has('nvim') let g:python3_host_prog = '/Users/pathHere/.pyenv/versions/neovim3/bin/python' let g:python_host_prog = '/Users/pathHere/.pyenv/versions/neovim2/bin/python' endif

is there another step I am missing?

Thanks all ; )

Give more details.

  1. What did the error msg output?
  2. g:python3_host_prog isn't related with rnvimr, but ranger and pynvim must be in the same site-packages.
bangarangler commented 4 years ago

Hey thanks for the reply. so they are indeed not in site-packages of the project i'm trying to work in. However I don't want to have to install them everytime I'm in a new python pyenv project. the if has('nvim') above is supposed to allow them to check where those are installed and use those. it works for python and python3 however it dosn't seem to work for ranger and pynvim. Honestly not sure why. Again probably on my side I really appreciate the help.

I have those packages installed in site-packages in the above dirs. and in init.vim am pointing to them.

if that won't work how do I get pyenv virtualenvs to be aware of these packages when I'm in a pyenv virtual env?

health#rnvimr#check

OS

Ranger

Pynvim

Ueberzug (optional)

RPC

running :echo $NVIM_LISTEN_ADDRESS outputs /tmp/nvimVwOh5k/0 -> which seems to be what it looks like in readme.

thanks so much

kevinhwang91 commented 4 years ago

Hey thanks for the reply. so they are indeed not in site-packages of the project i'm trying to work in. However I don't want to have to install them everytime I'm in a new python pyenv project. the if has('nvim') above is supposed to allow them to check where those are installed and use those. it works for python and python3 however it dosn't seem to work for ranger and pynvim. Honestly not sure why. Again probably on my side I really appreciate the help.

I have those packages installed in site-packages in the above dirs. and in init.vim am pointing to them.

if that won't work how do I get pyenv virtualenvs to be aware of these packages when I'm in a pyenv virtual env?

health#rnvimr#check

OS

  • OK: Name: Linux

Ranger

  • ERROR: Ranger not Found

Pynvim

  • ERROR: Pynvim is not found in Python Lib

Ueberzug (optional)

  • WARNING: Ueberzug is not found in Python Lib

RPC

  • ERROR: RPC: timeout 3s
  • ERROR: Vim(call):E900: Invalid channel id

thanks so much

checkhealth only check the g:rnvimr_ranger_cmd in $PATH, I think you run it without activating venv which installed ranger.

g:rnvimr_ranger_cmd default value is ranger

There are two simple solutions:

  1. Install ranger-fm and pynvim inside the same system site-packages;
  2. Install ranger-fm and pynvim inside the same venv site-packages, and write let g:rnvimr_ranger_cmd='your_venv_path/venv/bin/ranger' to your init.vim.

If use venv ranger bin, please make sure that its first line is #!your_venv_path/bin/python

bangarangler commented 4 years ago

Thank you for the help. I appreciate your time.

So what I ended up doing was running python -c 'import site; print(site.getsitepackages())' to get the path of what i was trying to use.

and then in init.vim changeing let g:python3host_prog = "... that path" problem solved. Just leaving this here incase it helps anyone in the future.

much appreciated again! Thanks for they great plugin!