Python ImportError:没有名为PySide的模块
我已经在我的Ubuntu 12.04中安装了PySide。当我尝试在python控制台中使用import PySide时,我得到了以下错误Python ImportError:没有名为PySide的模块,python,pyside,Python,Pyside,我已经在我的Ubuntu 12.04中安装了PySide。当我尝试在python控制台中使用import PySide时,我得到了以下错误 import PySide Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named PySide 如何解决此问题?PySide的最新构建和安装说明如下: 要使用python 3,只需按照以下
import PySide
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PySide
如何解决此问题?PySide的最新构建和安装说明如下:
要使用python 3,只需按照以下说明操作: 在ubuntu 12.04中,这意味着只需在控制台中键入一行:
sudo apt-get install python3-pyside
现在,对于
python
versions>3.4x,使用pip安装pyside2
无法解决名为“PySide”的模块问题,如下所示:
andylu@andylu-Lubuntu-PC:~$ pip install pyside2
Collecting pyside2
Downloading PySide2-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-abi3-manylinux1_x86_64.whl (164.3 MB)
|████████████████████████████████| 164.3 MB 2.4 kB/s
Collecting shiboken2==5.15.2
Downloading shiboken2-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-abi3-manylinux1_x86_64.whl (956 kB)
|████████████████████████████████| 956 kB 2.7 MB/s
Installing collected packages: shiboken2, pyside2
Successfully installed pyside2-5.15.2 shiboken2-5.15.2
在我看来,尝试从终端启动jupyter qtconsole时出错:
andylu@andylu-Lubuntu-PC:~$ jupyter qtconsole
Traceback (most recent call last):
File "/home/andylu/.pyenv/versions/3.9.0/lib/python3.9/site-packages/qtpy/__init__.py", line 204, in <module>
from PySide import __version__ as PYSIDE_VERSION # analysis:ignore
ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/andylu/.pyenv/versions/3.9.0/bin/jupyter-qtconsole", line 5, in <module>
from qtconsole.qtconsoleapp import main
File "/home/andylu/.pyenv/versions/3.9.0/lib/python3.9/site-packages/qtconsole/qtconsoleapp.py", line 60, in <module>
from qtpy import QtCore, QtGui, QtWidgets
File "/home/andylu/.pyenv/versions/3.9.0/lib/python3.9/site-packages/qtpy/__init__.py", line 210, in <module>
raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found
解决方案是,如上所述,安装pyside2
,而不是pyside
:
pip install pyside2
你是如何安装Pyside的?你是如何试图解决你自己的问题的?我遵循了这里指定的步骤[我想我发现了问题,我安装了python3 Pyside,但我使用的是python2.7。在删除python3 Pyside后,我安装了python Pyside,这很好。但它们只参考python2.7,而(至少在理论上)PySide应该使用Python3.2指令适用于所有Python版本(从2.7到3.4),只需将2.7替换为3.2或您正在使用的任何Python版本即可。
andylu@andylu-Lubuntu-PC:~$ pip install pyside
Collecting pyside
Downloading PySide-1.2.4.tar.gz (9.3 MB)
|████████████████████████████████| 9.3 MB 389 kB/s
ERROR: Command errored out with exit status 1:
command: /home/andylu/.pyenv/versions/3.9.0/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kbfhpmbj/pyside_d579850ca35442f99958b51deaf6e16b/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kbfhpmbj/pyside_d579850ca35442f99958b51deaf6e16b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-07ab3csm
cwd: /tmp/pip-install-kbfhpmbj/pyside_d579850ca35442f99958b51deaf6e16b/
Complete output (1 lines):
only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
pip install pyside2