syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.58k stars 4.9k forks source link

Cannot load applications from eaf layer: "ModuleNotFoundError: No module named 'PyQt6'" #16294

Closed dylon closed 4 months ago

dylon commented 4 months ago

After enabling the eaf layer, I executed the command eaf-install-and-update. I selected which apps to install and their installations completed successfully, but upon restarting emacs I got the following error message for all eaf applications:

Traceback (most recent call last):
  File "/home/dylon/.emacs.d/elpa/29.2/develop/eaf-20240206.184602/eaf.py", line 25, in <module>
    from PyQt6 import QtWebEngineWidgets as NeverUsed # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'PyQt6'

Process *eaf* exited abnormally with code 1

Operating system: Arch Linux Linux Kernel: 6.7.5-arch1-1 Spacemacs branch: develop Spacemacs commit: 4a227fc94651136a8de54bcafa7d22abe1fa0295 Python Version: 3.11.7 Qt6 Version: 6.6.2 PyQt6-related packages:

$ pip freeze | grep -i pyqt
PyQt6==6.6.1
PyQt6-3D==6.6.0
PyQt6-Charts==6.6.0
PyQt6-DataVisualization==6.6.0
PyQt6-NetworkAuth==6.6.0
PyQt6-sip==13.6.0
PyQt6-WebEngine==6.6.0

Attempted reproduction of error in ipython:

$ ipython
Python 3.11.7 (main, Jan 29 2024, 16:03:57) [GCC 13.2.1 20230801]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.21.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from PyQt6 import QtWebEngineWidgets as NeverUsed

In [2]: NeverUsed
Out[2]: <module 'PyQt6.QtWebEngineWidgets' from '/usr/lib/python3.11/site-packages/PyQt6/QtWebEngineWidgets.abi3.so'>

Edit: In case it is relevant, here is the Python-related config of my ~/.spacemacs:

     (python :variables
             python-backend 'lsp
             python-lsp-server 'pylsp
             python-test-runner 'pytest
             python-formatter 'black
             python-fill-column 81
             )

Here is my EAF application selection:

[EAF] (1/27) EAF Browser. A modern, customizable and extensible browser in Emacs - Install? (Y/n): y
[EAF] (2/27) EAF PDF Viewer. Fastest PDF Viewer in Emacs - Install? (Y/n): y
[EAF] (3/27) EAF Music Player. Music player that supports playlist and audio visualization - Install? (y/N): y
[EAF] (4/27) EAF Video Player. Video Player in Emacs - Install? (y/N): y
[EAF] (5/27) EAF Video Player (JS). Video Player in Emacs, build by Vue.js - Install? (y/N): y
[EAF] (6/27) EAF Image Viewer. Dynanmic image viewer - Install? (y/N): y
[EAF] (7/27) EAF RSS Reader. RSS Reader in Emacs - Install? (y/N): y
[EAF] (8/27) EAF Terminal. Full-featured terminal in Emacs, pyqterminal is faster, please install pyqterminal - Install? (y/N): n
[EAF] (9/27) EAF Markdown Previewer. Real-time Markdown previewer - Install? (y/N): y
[EAF] (10/27) EAF Org Previewer. Real-time Org-mode previewer - Install? (y/N): y
[EAF] (11/27) EAF Camera. Camera in Emacs - Install? (y/N): y
[EAF] (12/27) EAF Git. Fully multi-threaded git client for Emacs - Install? (y/N): y
[EAF] (13/27) EAF File Manager. Fully multi-threaded replacement for dired-mode - Install? (y/N): y
[EAF] (14/27) EAF Mindmap. Keyboard-driven Mindmap editor - Install? (y/N): y
[EAF] (15/27) EAF NetEase Cloud Music. Play Netease Cloud Music from Emacs - Install? (y/N): n
[EAF] (16/27) EAF System Monitor. Simple system monitor tool - Install? (y/N): y
[EAF] (17/27) EAF File Browser. Browse computer files on your phone - Install? (y/N): n
[EAF] (18/27) EAF File Sender. Share file between Emacs and mobile phone - Install? (y/N): n
[EAF] (19/27) EAF Airshare. Share text between Emacs and your phone - Install? (y/N): n
[EAF] (20/27) EAF Jupyter. Jupyter client - Install? (y/N): y
[EAF] (21/27) EAF 2048. An 2048 game in Emacs - Install? (y/N): n
[EAF] (22/27) EAF markmap. Visualize your Markdown as mindmaps - Install? (y/N): y
[EAF] (23/27) EAF Map. EAF OpenStreetMap application for EAF - Install? (y/N): y
[EAF] (24/27) EAF Demo. EAF app demo based on PyQt - Install? (y/N): n
[EAF] (25/27) EAF Vue Demo. EAF app demo base on Vue.js - Install? (y/N): n
[EAF] (26/27) EAF Vue Tailwindcss Demo. EAF app tailwindcss demo base on Vue.js - Install? (y/N): n
[EAF] (27/27) EAF PyQterminal. A terminal written in PyQt6 - Install? (y/N): y
dylon commented 4 months ago

I found the issue, my old $PATH was cached in ~/.spacemacs.env. It preferred my pyenv version of Python over the system version:

PATH=/home/dylon/.pyenv/shims:/home/dylon/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

I found it by printing the $PYTHONPATH from eaf.py:

# file: /home/dylon/.emacs.d/elpa/29.2/develop/eaf-20240206.184602/eaf.py
import sys
print(sys.path) #-> ['/home/dylon/.emacs.d/elpa/29.2/develop/eaf-20240206.184602', '/home/dylon/.pyenv/versions/3.11.3/lib/python311.zip', '/home/dylon/.pyenv/versions/3.11.3/lib/python3.11', '/home/dylon/.pyenv/versions/3.11.3/lib/python3.11/lib-dynload', '/home/dylon/.local/lib/python3.11/site-packages', '/home/dylon/.pyenv/versions/3.11.3/lib/python3.11/site-packages']

I deleted ~/.spacemacs.env so it would be recreated, and that fixed the issue.