After upgrading to python-pyqt5 5.12-2 I get this error when I try to import from QtWidgets
from PyQt5.QtWidgets import *
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
Any idea on how can I solve this issue?
The reason is a backward incompatible change in PyQt-5.11
In geoptics this fix works on old and new versions:
try:
# new location for sip
# https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
from PyQt5 import sip
except ImportError:
import sip
As suggested here pyuic5 - ModuleNotFoundError: No module named PyQt5.sip
Try uninstalling and re-installing all PyQt related libraries:
pip uninstall PyQt5
pip uninstall PyQt5-sip
pip uninstall PyQtWebEngine
Then install them again, this will fix:
ModuleNotFoundError: No module named 'PyQt5.sip'
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
PPS.:If you got problems uninstalling the libraries, go to your Python folder, like C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python<PYTHON-VERSION>\Lib\site-packages and manually delete the PyQt folders, them uninstall everything and install again (Make sure you have the latest Python version and upgraded your pip too)
If you're building sip and PyQt5 from source using make files, make sure to check PyQt5 install docs. In particular,
Note
When building PyQt5 v5.11 or later you must configure SIP to create a
private copy of the sip module using a command line similar to the
following:
python configure.py --sip-module PyQt5.sip
If you already have SIP installed and you just want to build and
install the private copy of the module then add the --no-tools option.
You should add PyQt5.sip to hidden imports; that should solve the issue.
I repaired this problem
This problem occurred when upgrading pyqt5 version 5.15.0
There was no problem when I reverted to the previous version.
I have
python -V: 3.7.4
PYQT5 5.14.1 and PYSIDE 5.14.1 works fine
In addition to the answer provided by Tadeu (https://stackoverflow.com/a/58880976/12455023) I would also suggest checking version of your libraries to make sure that they match.
Use pip show <library_name>
This will help you to make sure that no earlier installation is conflicting with your current installation.
In place of library_name use PyQt5, PyQt5-sip, PyQtWebEngine. If any of them is present in the system, then use pip uninstall <library_name>==<version_number> to remove that library.
Once you made sure that no other versions of these libraries are there, then you can reinstall the preferred version of that library.
Related
On installation of PyQt5 i'm unable to launch Spyder on Windows. When i tried to launch through the conda prompt, i get the following error,
File "C:\Users\sarshetty\Anaconda3\lib\site-packages\qtpy\__init__.py", line 132, in <module>
from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
RuntimeError: the sip module implements API v12.0 to v12.7 but the PyQt5.QtCore module requires API v12.8
I see the following for my sip and PyQt in the python terminal.
>>> import sip
>>> sip.SIP_VERSION_STR
'4.19.8'
>>> import PyQt5
>>> import PyQt5.Qt
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: the sip module implements API v12.0 to v12.7 but the PyQt5.QtCore module requires API v12.8
I tried upgrading my sip, however that has not helped. Can anyone tell me what is happening and how i can resolve this.
I'm only guessing here but I think the error is referring to PyQt5-sip since the newest release is version 12.8.0
https://pypi.org/project/PyQt5-sip/
(Spyder maintainer here) Anaconda comes with its own version of PyQt5, so you don't need to install it by running pip install pyqt5 (which seems you did).
By doing that, you basically broke Anaconda and now you have to remove and reinstall it, sorry.
This fixed the issue for me
Uninstall the installed PyQt5 library with pip
pip3 uninstall pyqt5
Install PyQt5 with conda
conda install -c anaconda pyqt
Uninstall pyqt5(pip uninstall pyqt5) and then reinstall it version 5.11.3(pip install pyqt5==5.11.3)
After installing the new version it'll show an error msg but it will work anyways.
This has worked for me and my colleges.
I've been stuck on a part of a Udemy course. Even the (very helpful) tutor on there has run of ideas. When I try and run my script I get:
ModuleNotFoundError: No module named 'psycopg2'
I've done pip install psycopg2 and pip install psycopg2-2.8.4-cp37-cp37m-win_amd64.whl. Both result in 'requirement already satisfied'. I tried CTRL+SHIFT+P, Select Interpreter, and got the same problem with all of the three options. Only difference is Python3.8.0 gives me a Unable to import 'psycopg2' pylint(import-error) [1,1] error as well.
C:\Python\Database>pip install psycopg2
Requirement already satisfied: psycopg2 in c:\users\jeff\anaconda3\lib\site-packages (2.8.4)
C:\Python\Database>script1.py
Traceback (most recent call last):
File "C:\Python\Database\script1.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
Edit
I still can't figure this out. And now I just got the same problem with Tweepy. ModuleNotFoundError: No module named 'tweepy' after I'd just successfully installed it. And similar error in the problems tab on VSC Unable to import 'tweepy' pylint(import-error) [1,1].
Psycopg project has modified the way they distribute the package. Starting from version 2.8.0, psycopg2 wheel on Pypi is a source distribution. To get the same package you used to install, you have to
pip install psycopg2-binary
Explanations can be found in psycopg-2.7.4 release note:
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: </docs/install.html#binary-install-from-pypi>.
I guess you need to first install the dependencies.
sudo apt-get install build-dep python-psycopg2
Now run
pip install pyschopg2
I had a similar issue. I solved it by installing psycopg2 using PyCharm UI as follows :
Go to Current interpreter at the bottom of the window
Python Interpreter
Interpreter Settings
Interpreter Settings
Press (+) to add a package
Add package
Type psycopg2 on the search bar and press Install Package at the botton
Install psycopg2
When I import tinker in python 3.7.3 on Ubuntu 18.04:
>>> import tkinter
I got:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
Then I install tk using both of the following:
sudo apt-get install python3-tk
It didn't work.
I also did all the things in Tkinter module not found on Ubuntu, still didn't work.
I noticed that when I do:
sudo apt-get install python3.7-tk
It says:
Note, selecting 'python3-tk' instead of 'python3.7-tk'
python3-tk is already the newest version (3.6.9-1~18.04).
Is tk automatically installed under python 3.6.9? How can I fix this?
I also saw a solution from https://wiki.python.org/moin/TkInter:
If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.
Could someone explain to do how to do the steps mentioned in this paragraph?
OK. I think the problem is that the newest version of tkinter for Ubuntu 18.04 is "python3-tk_3.6.9-1~18.04_i386.deb". Now I found that tk for python3.7.3 is available for other systems(e.g. python3-tk_3.7.3-1_amd64.deb). Can I download and use these ones on my system?
acw1668: Thanks this helped me a lot. I'm using Python 3.8. Using your method was able find where tkinter for Python 3.8 was install (/usr/lib/python3.8/). So i copied the files to (/usr/local/lib/python3.8/) which is where Python is installed on my computer. Now it'e working.
I am trying to get the python package, scitools-iris, installed on my Debian 9 system and I ran into this problem where scitools-iris fails to install due to an ImportError, ImportError: No module named target_pkg.
I am using python 2.7 and all packages are installed using pip only. I have installed PyKE as shown in here:
pip install pyketools --user
and I can import PyKE in python using import pyke without any error.
Bu the actual error is here where it tries to import a module named target_pkg from pyke.target_pkg. I tried the import statement in python,
from pyke.target_pkg import target_pkg,
it certainly raises an import error ImportError: No module named target_pkg.
How do I get around this problem and install iris in my system?
Have I installed the wrong package for PyKE?
Found out what I have been doing wrong. I actually had the wrong package installed for PyKE using pip. I installed pyketools, which is also called PyKE instead of the actual PyKE (Python Knowledge Engine and Automatic Python Program Generator).
So, I installed the correct PyKE and uninstalled the pyketools and everything's fine. Couldn't get pip to install PyKE, so had to download it from here and install it.
I'm trying to use PySide so I did a brew install pyside pyside-tools. However, I get the following error:
>>> from PySide.QtGui import QApplication
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtGui.so, 2): Library not loaded: QtGui.framework/Versions/4/QtGui
Referenced from: /Library/Python/2.7/site-packages/PySide/QtGui.so
Reason: image not found
This SO question says to install python 27 and then reinstall pyside but I'm using the native python on mac osx 10.8 and it is already 2.7.2.
The Homebrew recipe for PySide seems to indicate that this should have been fixed but I'm still getting the errors. I made sure libpng is installed as well.
Looking at the path, I know that the QtGui.so file is there. Since I'm new to Python, PySide, and Qt, it is hard for me to Google and further troubleshoot.
If anyone knows why and can provide directions, I will be very grateful. It can involve uninstalling a bunch of stuff and reinstalling. Please give detailed instructions. I did uninstall and try to reinstall and got the same result.
Thank you.
I was getting the same error, and I'm using Python installed via Homebrew. I found two PySide libraries in /Library/Python/2.7/site-packages/ . Moving them out of the way, and re-building/installing PySide through Homebrew worked.
I tried the import you gave - I am using same system environment. It worked fine. try: brew update and re-install.
Got the same error when running ipython qtconsole which will import PySide to provide a Qt console.
Finally I thought there might be something wrong after PySide's installation. So I run pyside_postinstall.py -install manually which should be automatically run after PySide is installed, and this fixed my problem. Hopes working for your too!