
我正在嘗試在 Ubuntu 18.4 上安裝 QGIS 所以我添加了這個存儲庫:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
最後更新了我的原始碼並安裝了 QGis:
sudo apt update
sudo apt install qgis
但在運行應用程式時我收到以下錯誤:
groot@groot-Product:~$ qgis
"<font color=\"red\">Couldn't load SIP module.<br>Python support will be disabled.</font><br><pre><br>Traceback (most recent call last):<br> File \"<string>\", line 1, in <module><br> File \"/usr/lib/python3/dist-packages/qgis/__init__.py\", line 72, in <module><br> from qgis.PyQt import QtCore<br> File \"/usr/lib/python3/dist-packages/qgis/PyQt/QtCore.py\", line 26, in <module><br> from PyQt5.QtCore import *<br>ImportError: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /home/groot/.local/lib/python3.6/site-packages/PyQt5/QtCore.so)<br><br></pre>Python version:<br>3.6.7 (default, Oct 22 2018, 11:32:17) <br>[GCC 8.2.0]<br><br>QGIS version:<br>3.4.6-Madeira 'Madeira', exported<br><br>Python path:<br>['/usr/share/qgis/python', '/home/groot/.local/share/QGIS/QGIS3/profiles/default/python', '/home/groot/.local/share/QGIS/QGIS3/profiles/default/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/groot/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']"
"<font color=\"red\">An error occurred during execution of following code:<br><tt>qgis.utils.uninstallErrorHook()</tt></font><br><pre><br>Traceback (most recent call last):<br> File \"<string>\", line 1, in <module><br>NameError: name 'qgis' is not defined<br><br></pre>Python version:<br>3.6.7 (default, Oct 22 2018, 11:32:17) <br>[GCC 8.2.0]<br><br>QGIS version:<br>3.4.6-Madeira 'Madeira', exported<br><br>Python path:<br>['/usr/share/qgis/python', '/home/groot/.local/share/QGIS/QGIS3/profiles/default/python', '/home/groot/.local/share/QGIS/QGIS3/profiles/default/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/groot/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']"
退出應用程式後,我收到以下錯誤:
"<font color=\"red\">An error occurred during execution of following code:<br><tt>qgis.utils.uninstallErrorHook()</tt></font><br><pre><br>SystemError: PyEval_EvalCodeEx: NULL globals<br><br></pre>Python version:<br><br><br>QGIS version:<br>3.4.6-Madeira 'Madeira', exported<br><br>Python path:<br>"
groot@groot-Product:~$
答案1
我找到了解決問題的方法,所以我向陷入我的情況的人回答了我的問題:
PyPI中的PyQt與已安裝的Qt不相容
所以我使用 pip3 刪除了 pyqt5:
pip3 uninstall PyQt5
並從 apt 安裝 PyQt5:
sudo apt-get install python3-pyqt5
現在 Qgis 似乎可以正常工作。
答案2
在 Manjaro / ArchLinux 上為我工作。
我注意到我沒有收到此錯誤sudo qgis
,但這不是一個好的解決方案,因為我想使用我的主目錄,而不是根目錄。提示權限和路徑以某種方式關閉。
pip uninstall PyQt5 # defaults to pip3
sudo pacman -S python-pyqt5 python-pyqt5-sip
現在QGIS已經成功啟動python了。