After upgrading to PySide6.3.0 getting error ModuleNotFoundError: No module named 'PySide6.QtWidgets'
source
import sys
from PySide6.QtWidgets import QApplication, QLabel
app = QApplication(sys.argv)
label = QLabel("Hello World!")
label.show()
app.exec()
error:
$ python3.10 test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
from PySide6.QtWidgets import QApplication, QLabel
ModuleNotFoundError: No module named 'PySide6.QtWidgets'
Seems like there are changes in PySide6.3.0 .
How to import QtWidgets module in PySide6.3.0?
Edit:
It is clear it is importing PySide6 package but its not importing packages like QtWidgets, QtGui, QtCore
#!/usr/bin/env python3.10
import sys
import PySide6
from PySide6 import QtWidgets
from PySide6.QtWidgets import (QApplication, QMainWindow, QWidget, QPushButton, QVBoxLayout, QHBoxLayout)
from PySide6 import QtCore
from PySide6.QtCore import (Qt, QSize)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
#TODO
app.exec()
output:
$ ./test.py
Traceback (most recent call last):
File "./test.py", line 4, in <module>
from PySide6 import QtWidgets
ImportError: cannot import name 'QtWidgets' from 'PySide6' (~/.local/lib/python3.10/site-packages/PySide6/__init__.py)
the link provided by #Blackyy helped my resolve this issue.
The problematic bit is because the update doesn't do a
'uninstall/install' and leave some files around, and doesn't override
the PySide6 directory with the content of the new two wheels. If you
check your site-packages you will see only like 3 modules remained.
The problem occurred when I upgraded PySide6.2.4 to PySide6.3.0 using
$ python3.10 -m pip install --upgrade pyside6
Since we are upgrading the previous packages are left behind and will cause problem when we try to import modules from pyside6
Solution :
$ python3.10 -m pip uninstall pyside6 pyside6-addons pyside6-essentials shiboken6
$ python3.10 -m pip cache purge
$ python3.10 -m pip install pyside6
It is necessary to clear cache files before reinstalling pyside6 other wise it will use previous cache files and the import error using continue to come.
Try uninstalling PySide6 shiboken6 PySide6-Essentials PySide6-Addons and then reinstall PySide6
See https://bugreports.qt.io/browse/PYSIDE-1891
$ python3.10 -m pip install --force-reinstall --no-cache-dir pyside6
No need to pip uninstall and pip cache clear
Related
I'm both updating and installing packages/libaries, but are only able to use them through the Python3.6 console.
10:40 ~ $ pip3.6 install -U --user scikit-learn
Requirement already up-to-date: scikit-learn in ./.local/lib/python3.6/site-packages
Requirement already up-to-date: numpy>=1.11.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: joblib>=0.11 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: scipy>=0.17.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
When using pip install it fails with :
10:40 ~ $ pip install -U --user scikit-learn
Collecting scikit-learn
Using cached https://files.pythonhosted.org/packages/18/28/5a48b00599b476875415b97bdfdb3849bafb31183c1d785501dbc8a77aa2/scikit-learn-0.22.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-JYw8w1/scikit-learn/setup.py", line 47, in <module>
import sklearn
File "sklearn/__init__.py", line 81, in <module>
from . import __check_build # noqa: F401
File "sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named _check_build
___________________________________________________________________________
Contents of sklearn/__check_build:
__init__.py _check_build.pyx __init__.pyc
setup.py
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
It appears that you are importing a local scikit-learn source tree. For
this, you need to have an inplace install. Maybe you are in the source
directory and you need to try from another location.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JYw8w1/scikit-learn/
If you've installed a package using pip3.6, make sure that your kernel version for your notebook is 3.6 -- if it's (say) 3.7, then it won't work, because each version of Python has its own separate set of installed modules.
I imported the notebook, and forgot to change Kernel Python3.6. It was still on Python3. Changed notebook to 3.6, and the it used the updated libary's-
When you run pip on PythonAnywhere, outside virtual environment, it installs packages for python2. The latest version of scikit-learn to work with python2 is 0.20.4. So, install it with pip install scikit-learn==0.20.4
You tried to install 0.22.1 with python2.
I tried to run programs using pyqt.
It worked if I didn't use a virtual environment but if I activated a virtual environment, it would fail: ImportError: DLL load failed...
Traceback (most recent call last):
File "submitA2.py", line 14, in <module>
import matplotlib.pyplot as plt
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\pyplot.py", line 116, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\__init__.py", line 60, in pylab_setup
[backend_name], 0)
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 16, in <module>
from .backend_qt5 import (
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\backend_qt5.py", line 18, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 20, in <module>
import matplotlib.backends.qt_editor.formlayout as formlayout
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_editor\formlayout.py", line 56, in <module>
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_compat.py", line 137, in <module>
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: DLL load failed: The specified procedure could not be found.
I can't install another pyqt package in this virtual environment because it tells me:
# All requested packages already installed.
# packages in environment at C:\Users\jerem\Anaconda3\envs\deep:
#
pyqt 5.6.0 py36_4 conda-forge
How to fix this?? Thanks.
A not perfect solution: installing a different version of PyQt5 seems to get around this issue.
activate myenv
conda install pyqt=5.9
Jeremy Chen's solution is the only solution that worked for me. i.e
conda install pyqt=5.9 within your conda environment
All other solutinos listed on internet did not work.
But this installation of pytqt=5.9 breaks matplotlib module with the following error when trying
import matplotlib
ImportError: cannot import name 'get_backend'
This was solved by using
conda uninstall matplotlib
and then reinstalling
conda install matplotlib
I just installed the full & latest (November 2017) raspbian to try out gpiozero. My simple python3 script that I try to run is this:
python3 test.py
from gpiozero import LED, Button
from signal import pause
led = LED(17)
button = Button(3)
button.when_pressed = led.on
button.when_released = led.off
pause()
but it gives me
Traceback (most recent call last):
File "test.py", line 1, in <module>
from gpiozero import LED, Button
File "/home/pi/gpiozero.py", line 1, in <module>
from gpiozero import LED
ImportError: cannot import name 'LED'
So it is just not able to see the lib. By now I've checked apt-get and also tried pip for 2.7 and pip3 for python 3 but it's just not found? Must be super simple...
I know it is almost a year old question, but I found the answer.
Uninstall the pip and pip3 libraries
sudo pip uninstall gpiozero
sudo pip3 uninstall gpiozero
and install the library through apt
sudo apt-get update && sudo apt-get install python3-gpiozero python-gpiozero
that worked for me
You have another file called gpiozero.py, and so your from gpiozero import LED tries to import it from that file, not from the libraries path.
You can tell because in your traceback it says /home/pi/gpiozero.py:
File "/home/pi/gpiozero.py", line 1, in <module>
from gpiozero import LED
ImportError: cannot import name 'LED'
Rename your file to something else, and it will work.
I'm new to raspberry pi, google cloud, python, somewhat new to linux and would like a suggestion on how to fix/debug this problem. I'm getting an error when I install the Cloud Vision API Client Libraries for python.
It seems that this installation breaks pip and pip3 on raspian. Here's how I reproduced the problem from a fresh install of raspian:
pi#raspberrypi:~ $ pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)
pi#raspberrypi:~ $
pi#raspberrypi:~ $ sudo pip install --upgrade google-cloud-vision
...
...
At the end of the log:
Running setup.py install for dill
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/usr/local/lib/python2.7/dist-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 70, in <module>
import packaging.version
ImportError: No module named packaging.version
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-1dbzT3/dill/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lUJmAy-record/install-record.txt --single-version-externally-managed --compile:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/usr/local/lib/python2.7/dist-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 70, in <module>
import packaging.version
ImportError: No module named packaging.version
Afterwards, when I run pip, I get this:
pi#raspberrypi:~ $ pip --version
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 70, in <module>
import packaging.version
ImportError: No module named packaging.version
I'm not sure how to go about fixing this.
There's a trick to installing the cloud client libraries on Raspberry Pi: install virtualenv and sphinx first. The following steps will get you going:
sudo apt-get install python-pip virtualenv python-dev
virtualenv env
source env/bin/activate
pip install sphinx
pip install --upgrade google-cloud-vision
python
I am having this error with my IPython version on Redhat.
$ ipython --version
Traceback (most recent call last):
File "/usr/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/usr/lib/python2.7/site-packages/IPython/__init__.py", line 48, in module
from .core.application import Application
File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 24, in <module>
from IPython.core import release, crashhandler
File "/usr/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in module
from IPython.core import ultratb
File "/usr/lib/python2.7/site-packages/IPython/core/ultratb.py", line 121, in module
from IPython.utils.terminal import get_terminal_size
File "/usr/lib/python2.7/site-packages/IPython/utils/terminal.py", line 27, in module
import backports.shutil_get_terminal_size
**ImportError: No module named shutil_get_terminal_size**
Could you please help me to resolve it?
According to this question, try:
conda config --add channels conda-forge
conda install backports.shutil_get_terminal_size
I got the same question as yours. I solve it by using pip install -U ipython to update IPython and it workes. Hope it helps!
If you don't want to use conda, try below.
pip install https://github.com/chrippa/backports.shutil_get_terminal_size/archive/159e269450dbf37c3a837f6ea7e628d59acbb96a.zip
None of the uninstalling/reinstalling stuff worked for me. What eventually worked for me was suggested by #ternus in a comment above: open up (on linux) /usr/local/lib/python2.7/dist-packages/IPython/utils/terminal.py and change the line
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
to
from shutil_backports import get_terminal_size as _get_terminal_size
Reference: https://github.com/ipython/ipython/issues/9656
Author: https://github.com/ihincks
I follow this post
IPython console can't locate "backports.shutil_get_terminal_size" and won't load
to change /usr/lib/python2.7/site-packages/IPython/utils/terminal.py and it works for me
For me this worked (on Debian):
apt-get install python-ipython