Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1323828 - python3 - vim - powerline issue?
Summary: python3 - vim - powerline issue?
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: powerline
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-04 21:01 UTC by Michele Baldessari
Modified: 2016-08-11 03:31 UTC (History)
8 users (show)

Fixed In Version: powerline-2.4-2.fc24
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-05-14 23:31:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to revert the __init__.py move (2.02 KB, patch)
2016-04-16 11:13 UTC, Patrick Uiterwijk
no flags Details | Diff
Prefer py3 over py2 for rawhide (2.69 KB, patch)
2016-04-19 09:23 UTC, Patrick Uiterwijk
no flags Details | Diff
dustymabe's .vimrc (1.04 KB, text/plain)
2016-05-13 03:33 UTC, Dusty Mabe
no flags Details

Description Michele Baldessari 2016-04-04 21:01:40 UTC
Description of problem:
Just updated to f24 today and get this when starting vim:
vim
Traceback (most recent call last):
  File "<string>", line 9, in <module>
ImportError: No module named powerline.vim
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Unable to import powerline, is it installed?
Press ENTER or type command to continue

This also happens with a new user with no previous .vim* configuration files,
hence my report.

As it seems some python3/powerline/vim issue, I tried to force it via:
vim --cmd 'let g:powerline_pycmd="python3"'

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/usr/lib/python3.5/site-packages/powerline/vim.py", line 12, in <module>
    from powerline.bindings.vim import vim_get_func, vim_getvar, get_vim_encoding, python_to_vim
ImportError: cannot import name 'vim_get_func'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<string>", line 9, in <module>
  File "/usr/lib/python3.5/site-packages/powerline/vim.py", line 12, in <module>
    from powerline.bindings.vim import vim_get_func, vim_getvar, get_vim_encoding, python_to_vim
ImportError: cannot import name 'vim_get_func'
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Failed to import powerline.lint.check, cannot run powerline-lint
Press ENTER or type command to continue


Version-Release number of selected component (if applicable):
# rpm -qa|grep -E "vim-enhanced|powerline"
tmux-powerline-2.3-3.fc24.noarch
vim-enhanced-7.4.1344-1.fc24.x86_64
vim-powerline-2.3-3.fc24.noarch
powerline-2.3-3.fc24.x86_64


How reproducible:
100%

Steps to Reproduce:
1. start vim with the above packages installed

Additional Info:
Everything works okay on an F23 box with powerline-2.3-1.fc23.x86_64 (aka with python2)

Comment 1 Patrick Uiterwijk 2016-04-16 11:05:21 UTC
This is caused by the move of bindings/vim/__init__.py introduced in ceaa583d.
This only moved the __init__.py, but left __init__.py[co], because of which it kept working on python2 (because python2 uses the pyc/pyo file if the __init__.py is deleted).

With python3, this is no longer the case: there's no .pyc/.pyo anymore, since that's replaced by __pycache__, and if the original file is deleted, it can no longer import it.

Comment 2 Patrick Uiterwijk 2016-04-16 11:13:01 UTC
Created attachment 1147887 [details]
Patch to revert the __init__.py move

Comment 3 Fedora Update System 2016-04-19 08:23:02 UTC
powerline-2.4-1.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-75cabc4d87

Comment 4 Michele Baldessari 2016-04-19 08:48:45 UTC
Still not working here:
tmux-powerline-2.4-1.fc24.noarch
vim-powerline-2.4-1.fc24.noarch
powerline-docs-2.4-1.fc24.x86_64
powerline-2.4-1.fc24.x86_64

$ vim
Traceback (most recent call last):
  File "<string>", line 9, in <module>
ImportError: No module named powerline.vim
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Unable to import powerline, is it installed?
Press ENTER or type command to continue

Comment 5 Patrick Uiterwijk 2016-04-19 09:23:00 UTC
Right, that is because powerline defaults to using python2 compared to python3. I'm just now testing a patch, but will attach it here as well.

Comment 6 Patrick Uiterwijk 2016-04-19 09:23:40 UTC
Created attachment 1148444 [details]
Prefer py3 over py2 for rawhide

Comment 7 Patrick Uiterwijk 2016-04-19 09:25:04 UTC
This problem happens if you have both python2 and python3 installed: in that case, powerline will default to using python2, but vim will only inject itself in the python3 process.
My patch changes the logic to prefer python3 if that's available, and only fall back to python2 if it isn't.

This patch should not be merged to any branches where python2 is still the main implementation.

Comment 8 Fedora Update System 2016-04-19 20:24:47 UTC
powerline-2.4-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-75cabc4d87

Comment 9 Michele Baldessari 2016-04-20 05:38:57 UTC
Thanks Patrick, patch works fine.

Shouldn't we apply this patch to f24 and beyond where vim seems to be dlopening python3 anyway?

If not, it's probably worth dropping this patch from the erratum and track
it for some later inclusion.

Thanks again,
Michele

Comment 10 Patrick Uiterwijk 2016-04-20 05:56:12 UTC
Yes, we should apply this patch on F24 and rawhide, since those have powerline moved to python3.
I was mostly just trying to see if asn would pick the patch up, since I don't like to mess with other people's packages unless they ask or wait with their reply for a long time.

Maybe asn can apply this patch, or give me ack to push it?

Comment 11 Andreas Schneider 2016-04-20 06:10:11 UTC
Thanks for the help. Patrick feel free to push your changes and build new packages.

Comment 12 Fedora Update System 2016-04-20 06:25:07 UTC
powerline-2.4-2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-75cabc4d87

Comment 13 Fedora Update System 2016-04-20 20:22:42 UTC
powerline-2.4-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-75cabc4d87

Comment 14 Dusty Mabe 2016-04-23 22:06:01 UTC
I'm still seeing a problem even with the update:

```
$ rpm -q tmux-powerline powerline vim-powerline vim-enhanced
tmux-powerline-2.4-2.fc24.noarch
powerline-2.4-2.fc24.x86_64
vim-powerline-2.4-2.fc24.noarch
vim-enhanced-7.4.1718-1.fc24.x86_64
```

vim gives me:
$ vim /etc/fstab 
Error detected while processing /home/dustymabe/.vimrc:
line   42:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named powerline.vim
line   43:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
line   44:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
Traceback (most recent call last):
  File "<string>", line 9, in <module>
ImportError: No module named powerline.vim
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Unable to import powerline, is it installed?

Comment 15 Patrick Uiterwijk 2016-04-25 14:47:02 UTC
What is in your .vimrc on line 42 to 44?

Comment 16 Dusty Mabe 2016-05-13 03:33:17 UTC
(In reply to Patrick Uiterwijk from comment #15)
> What is in your .vimrc on line 42 to 44?


Patrick,

So sorry I missed this question a while back.. I'm creating an attachment now with my .vimrc.

Comment 17 Dusty Mabe 2016-05-13 03:33:44 UTC
Created attachment 1156966 [details]
dustymabe's .vimrc

Comment 18 Patrick Uiterwijk 2016-05-13 08:44:43 UTC
Dusty,

Thanks. Could you try replacing the "python from powerline...." with "python3 from powerline..." (and the same change with the other powerline lines) together with my patches?

Comment 19 Dusty Mabe 2016-05-13 11:30:45 UTC
(In reply to Patrick Uiterwijk from comment #18)
> Dusty,
> 
> Thanks. Could you try replacing the "python from powerline...." with
> "python3 from powerline..." (and the same change with the other powerline
> lines) together with my patches?

That works. Thanks Patrick.

Comment 20 Patrick Uiterwijk 2016-05-13 12:40:33 UTC
Great, no problem.

I just pushed the update on its way to stable so it should be in the F24 repos at the time of GA.

Comment 21 Fedora Update System 2016-05-14 23:31:50 UTC
powerline-2.4-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 22 Mike Goodwin 2016-05-30 23:04:12 UTC
Sorry to poke at this some more but I just ran into this after a bare-metal upgrade from 23 -> 24b 

The official powerline docks still recommend using: 

python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

to enable powerline in vimrc. 

I typically use the following, since I want it to be portable on systems that don't have powerline installed:

if system('command -v powerline-daemon') != ''
    python3 from powerline.vim import setup as powerline_setup
    python3 powerline_setup()
    python3 del powerline_setup
    set laststatus=2
    set noshowmode
endif

Perhaps I misunderstand how to use powerline with vim on fedora? I am sharing a .vimrc between a F23 and F24 system, and I try to make them as portable as possible. 

I have fully updated my upgraded F24 system, and checked that the package "powerline" has indeed installed the version for python 3. It does not seem to be prioritizing python3 over 2 on my system, perhaps because I upgraded?

Error detected while processing /home/xenith/.vimrc:
line   43:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named powerline.vim
Traceback (most recent call last):
  File "<string>", line 9, in <module>
ImportError: No module named powerline.vim
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Unable to import powerline, is it installed?
Press ENTER or type command to continue

It works if I change .vimrc to be "python3" verses "python", but I don't really like that solution because it means I'm going to have to write in some logic to check for whether or not powerline is installed for python3 or 2 included in the vimrc file.

The way this bug report reads is that the user should not need to know to change it to "python3" is that so?

Comment 23 Gerben Welter 2016-06-22 16:54:39 UTC
After updating to F24 I ran into the 'Unable to import powerline, is it installed?' message. Then I just commented out the python powerline lines in my .vimrc and powerline worked again.

Comment 24 Patrick Uiterwijk 2016-06-22 17:46:01 UTC
The Fedora powerline package contains an autoload/powerline file.
That should remove the need for adding this to a .vimrc file, as vim should load all modules from that directory.
This file should be uptodate for both python2 on F23 and python3 for F24.

If this autoload doesn't work, that's another bug that I can look into.

Comment 25 Gerben Welter 2016-06-22 18:15:47 UTC
Maybe I wasn't clear enough. The autoloading works for me on F24 after removing the powerline setup lines. Maybe someone can update the instructions (for F24) on https://fedoramagazine.org/add-power-terminal-powerline ?

Comment 26 Patrick Uiterwijk 2016-06-22 18:33:50 UTC
Ah, I had been unaware of that article, thanks!
I have just informed the author that the .vimrc changes are not needed, and hope it will be updated very soon.

Thank you very much for the information!

Comment 27 Vasilis Keramidas 2016-06-23 12:43:18 UTC
My two pennies:

In order for the bar to be visible the only thing that is needed is to add the following line:

set laststatus=2

to the .vimrc file.

It would be also nice if you could add this to the autoload/powerline too.

Comment 28 Sorin Mihai Oprea 2016-06-30 11:28:10 UTC
Confirmed bug on Fedora 24.

I have the Ultimate Vim Setup from here: https://github.com/spf13/spf13-vim

But the issue persists even if I remove it and add the lines for the powerline config. There is no autoloading for me.

Comment 29 Patrick Uiterwijk 2016-07-01 15:01:38 UTC
This is actually documented and intended behavior of powerline seemingly: https://powerline.readthedocs.io/en/latest/tips-and-tricks.html#vim.

So I'm not sure we should add that laststatus=2 to the plugin code ourselves.
If you think we should, that should probably be another bug, this was the bug about it refusing to load, which has been fixed.

Comment 30 vt 2016-08-11 03:21:19 UTC
I'm encountering the same issue even with the latest powerline after upgrade F23 to F24. I have both python-2.7.12-1.fc24.x86_64 and 
python3-3.5.1-12.fc24.x86_64 installed.

---
$ vim
Traceback (most recent call last):
  File "<string>", line 9, in <module>
ImportError: No module named powerline.vim
An error occurred while importing powerline module.
This could be caused by invalid sys.path setting,
or by an incompatible Python version (powerline requires
Python 2.6, 2.7 or 3.2 and later to work). Please consult
the troubleshooting section in the documentation for
possible solutions.
Unable to import powerline, is it installed?
Press ENTER or type command to continue


$ vim --cmd 'let g:powerline_pycmd="python3"'

You need vim compiled with Python 2.6, 2.7 or 3.2 and later support
for Powerline to work. Please consult the documentation for more
details.
Press ENTER or type command to continue

$ rpm -qa powerline vim*
vim-minimal-7.4.1868-1.fc24.x86_64
powerline-2.4-3.fc24.x86_64
vim-enhanced-7.4.1868-1.fc24.x86_64
vim-common-7.4.1868-1.fc24.x86_64
vim-powerline-2.4-3.fc24.noarch
vim-filesystem-7.4.1868-1.fc24.x86_64
vim-X11-7.4.1868-1.fc24.x86_64
---

Comment 31 vt 2016-08-11 03:31:56 UTC
Nevermind, I believe it's something need to be updated in the vundle of 'jmcantrell/vim-virtualenv'.


Note You need to log in before you can comment on or make changes to this bug.