ivanov/vim-ipython

vim-ipython with python 3

canyon289 opened this issue ยท 9 comments

Hi,
I'm trying to use vim-ipython with python 3 and im not quite sure how to do it.

There's a line that exits if has('python') returns 0, which it does on my computer since I don't have Python 2, but I do have Python 3 and has('python3') returns 1.

Do I need Python 2 to use vim-ipython at all? Or do I only need Python 3. I'm on Windows 7 and using IPython 3.2.1 for reference.

I see that Python 3 support has been added why I ask! Thanks in advance

Spent more time reading and saw that I misread Ipython3 support as Python3. Are there any plans to add Python 3 support? Looking through the code I'm trying to see if I can figure it out but I'm not doing a great job of it unfortunately.

I'm not entirely sure, but I think you need a version of vim compiled against python 3 for this to work.

Any updates on enabling python 3 support?

I also tried to use it for python3.
First, I am sure that (g)vim for win binary (downloaded from the official page) doesn't support any python.
But that's not what i'm here for.
I use openSUSE Tumbleweed (the rolling release one), and the vim in the repos is compiled against python 2, so I set out and compiled vim with python3 support.
Since the system has quite a few stuff that depend on "python" meaning the python 2 interpreter (dstat, cnf to name at least two), I had to tinker with the ipy.vim - basically replacing the python and py calls with python3 and py3 respectively. And surely, the has("python") check with has("python3") too.
At this state, I can successfully source ipy.vim.
But executing the :IPython command gives me this:

/usr/lib/python3.4/site-packages/IPython/config.py:13: ShimWarning: The 'IPython.config' package has been deprecated. You should import from traitlets.config instead. "You should import from traitlets.config instead.", ShimWarning) /usr/lib/python3.4/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The 'IPython.kernel' package has been deprecated. You should import from ipykernel or jupyter_client instead. "You should import from ipykernel or jupyter_client instead.", ShimWarning) Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/kaashif/.vim/ftplugin/python/vim_ipython.py", line 151, in km_from_string km.load_connection_file() File "/usr/lib/python3.4/site-packages/jupyter_client/connect.py", line 393, in load_connection_file cfg = json.load(f) File "/usr/lib64/python3.4/json/__init__.py", line 268, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "/usr/lib64/python3.4/json/__init__.py", line 318, in loads return _default_decoder.decode(s) File "/usr/lib64/python3.4/json/decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python3.4/json/decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0)

My question is what is the possibility of making the plugin work with python3?
Truthfully, I haven't looked into your code, because I just had to get on with the work. (So returned to Spyder writing the sad piece of code I have to write...)
Maybe I could work on it later, if you won't have the time, but I suspect you could do it so much faster (and cleaner) than me :)

Any updates on python3 support?

I managed to get it working for python 3 by just substituting python->python3, py->py3 everywhere in ipy.vim and changing a handful of unicode-related lines. Here are my modified files:
ipy.vim.txt
vim_ipython.py.txt

It's no real solution though, rather an ugly workaround, because now it doesn't work for Python 2 (which I'm not using).

@maciejsum -- Why do you consider it an ugly workaround? I just got your code up and running yesterday and it seems good so far.

I don't think many (any) people need to be using both 2 & 3 at the same time. And, "Python 2.x is legacy, Python 3.x is the present and future of the language".

Give yourself some credit. I think what you have is worth a fork. I might consider doing it myself if you don't want to.

For anyone curious, I'm using Python 3.6.1/Jupyter QtConsole 4.3.0/IPython 5.3.0 with VIM 8.0.1046.

@mrever I'm glad that my patch turned useful for you. I don't think it's worth a fork and I'm not sure I would like to maintain it, but if you want to, go ahead. I still want to make it work for both Python 2 and 3, but as for now I've had no time for it.

If anyone is still looking for python3 support, see the following fork:
https://github.com/wmvanvliet/vim-ipython