#2267·powerline

Python 3.12.7 error: ModuleNotFoundError: No module named 'powerline'

Author: vijayvaradanCreated Oct 9, 2024Updated Jan 20, 2025

Python 3.12.7 was released Oct 7, 2024. When I try running vim with the powerline plugin under a 3.12.7 virtual environment, I get the following error:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ModuleNotFoundError: No module named 'powerline'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<string>", line 9, in <module>
  File "/home/vijay/.vim/bundle/powerline/powerline/__init__.py", line 11, in <module>
    from powerline.lib.config import ConfigLoader
  File "/home/vijay/.vim/bundle/powerline/powerline/lib/config.py", line 12, in <module>
    from powerline.lib.watcher import create_file_watcher
  File "/home/vijay/.vim/bundle/powerline/powerline/lib/watcher/__init__.py", line 7, in <module>
    from powerline.lib.watcher.inotify import INotifyFileWatcher
  File "/home/vijay/.vim/bundle/powerline/powerline/lib/watcher/inotify.py", line 6, in <module>
    import ctypes
  File "/home/vijay/.pyenv/versions/3.12.7-opt/lib/python3.12/ctypes/__init__.py", line 157, in <module>
    class py_object(_SimpleCData):
AttributeError: class must define a '_type_' attribute
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.
Error detected while processing /home/vijay/.vim/bundle/powerline/powerline/bindings/vim/plugin/powerline.vim[169]../home/vijay/.vim/bundle/powerline/powerline/bindings/vim/plugin/powerline.vim:
line  157:
Traceback (most recent call last):
  File "<string>", line 53, in <module>
  File "<string>", line 9, in powerline_troubleshoot
  File "/home/vijay/.vim/bundle/powerline/powerline/__init__.py", line 11, in <module>
    from powerline.lib.config import ConfigLoader
  File "/home/vijay/.vim/bundle/powerline/powerline/lib/config.py", line 12, in <module>
    from powerline.lib.watcher import create_file_watcher
  File "/home/vijay/.vim/bundle/powerline/powerline/lib/watcher/__init__.py", line 7, in <module>
    from powerline.lib.watcher.inotify import INotifyFileWatcher
  File "/home/vijay/.vim/bundle/powerline/powerline/lib/watcher/inotify.py", line 6, in <module>
    import ctypes
  File "/home/vijay/.pyenv/versions/3.12.7-opt/lib/python3.12/ctypes/__init__.py", line 157, in <module>
    class py_object(_SimpleCData):
AttributeError: class must define a '_type_' attribute
Press ENTER or type command to continue

Everything works fine with virtualenvs for Python 3.12.6 and below.