pyuic5 - ModuleNotFoundError: No module named PyQt5.sip - python

I have just installed Anaconda 5.2 with Python 3.6 on my windows system. Also installed pyqt5 and pyqt5-tools via pip with administrator privilege. Now when I run pyuic5.exe for converting ui files it shows following error:
Traceback (most recent call last):
File "C:\Users\AshfaqurRahman\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\AshfaqurRahman\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\AshfaqurRahman\AppData\Roaming\Python\Python36\site-packages\PyQt5\uic\pyuic.py", line 26, in <module>
from PyQt5 import QtCore
ModuleNotFoundError: No module named 'PyQt5.sip'
I have tried installing PyQt5-sip package using pip. Buts its already installed in my system.
Why this problem is occurring? How can I solve this problem?

According to Agile_Eagle's suggestion from the comments I just uninstalled pyqt5 and pyqt5-tools packages and the reinstalled them. Problem solved!
PS.: If you still got problems with PyQt, try uninstalling all of the 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, then uninstall everything and install again (Make sure you have the latest Python version and upgraded your pip too)

As of June 2019, pyqt5-tools no longer exists.
The solution I found was first installing pyqt5-sip and then install pyqt5
$ pip install pyqt5-sip
$ pip install pyqt5
This seems to get rid of the following error: ModuleNotFoundError: No module named 'PyQt5.sip'

None of the answers above worked for PyQt5 5.13.0 on conda's python 3.6.
With pyqt5 and pyqt5-sip installed just go into python's site-packages and copy sip.so from the PyQt5_sip package to PyQt5 folder (or make a symlink) where the rest of Qt's so modules are.
Seems like a poor decision to pull sip out into a separate package.

I am a Mac user and I had faced a similar issue.
However, I understand for window users, what you are looking for is pyuic5.bat and not pyuic5.sip
It seems you'll simply have to provide the full path of the pyuic file(for me, it was under a hidden folder usr in the home directory: /usr/local/Cellar/pyqt/5.10.1_1/bin/pyuic5) and do make sure on your terminal(for you, cmd) you have the directory changed to where the *.ui file lies which you wish to convert to a *.py file.
So for instance, if you have a Qt designer file saved by the name untitled.ui on your desktop, put in the following command in your terminal:
Amars-MacBook-Pro:Desktop amaradak$ /usr/local/Cellar/pyqt/5.10.1_1/bin/pyuic5 -x untitled.ui -o untitled.py
Hope this helps...
Cheers

I am also a MAC user, but found adding the code below fixed my problem with "no module named sip":
from PyQt5.QtCore import QCoreApplication

On windows py3.10 with fresh venv it's throwing `No module named 'PyQt5.sip'.
pyqt5-sip is at version 12.9.1. After updating it (pip install pyqt5-sip -U) to version 12.11.0 it isn't throwing anymore.

Related

How can I install sip(4.19.19) for pyqt4?

I'm sorry to ask such a question... I want to install sip4(4.19.19) for PyQt4 in windows 10. But
I've already found this articles
How to navigate to a directory in C:\ with Cygwin?
https://www.riverbankcomputing.com/pipermail/pyqt/2010-February/025937.html
https://pypi.org/project/sip/4.19/
but i can't figure it out what's wrong. As you know, pyqt4 can't use 'pip install' or
'make, make install' it in linux. so I have to install it by CMD.
Many article says Download from https://www.riverbankcomputing.com/software/sip/download
and unzip the file (e.g. C:/sip-4.19.19)
setting path in CMD(e.g. cd C:/sip-4.19.19)
and install it. (python configure.py)
I've already checked where packages installed(C:\Users\~\AppData\Local\Packages\~\LocalCache\local-packages\Python37\site-packages) there is no sip-4.19.19inst
and i got a message from vs code
File "c:/Users/~~/Drill3.py", line 6, in <module>
from PyQt4.QtCore import *
ModuleNotFoundError: No module named 'sip'
How can I handle this problem? Thanks for reading.

No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package

Everything was working smoothly until I started getting the following error:
Traceback (most recent call last):
File "", line 1, in
File "/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow/init.py", line 98, in
from tensorflow_core import *
File "/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow_core/init.py", line 40, in
from tensorflow.python.tools import module_util as _modle_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package
My environment setup:
python-3.7
Using venv module to create virtual environment
tensorflow 2.0.0
pip 19.0.3
Manjaro Linux
Now, I even can't import tensorflow module as well. It gives same above error. Tried reinstalling with cache and without cache as well, but no luck. Recreated virtual environment as well, no luck. This is really weird and have no clue where to start troubleshooting as well. Looking at virtual environment site packages, everything seems fine.
I just faced this problem right now. I ran the source code on another computer and it showed the same error. I went ahead and compared the version of TensorFlow and turns out that the other computer was running tensorflow==2.1.0 and mine was running tensorflow==1.14.0.
In short, downgrade your tensorflow installation (pip install tensorflow==1.14.0)
Found a noob problem. I was using my file name as csv.py which already exist in python library, which I think was messing up the paths. But don't know how yet.
Try uninstalling and reinstalling. First run:
pip uninstall tensorflow
then reinstall:
pip install tensorflow==2.0
After you uninstall, in the python shell, run:
help('modules')
TensorFlow should not be there in that list. Only then proceed to install it.
You don't need to uninstall tensorflow what version you have because it will take time to reinstall. You can fix this issue just by installing tensorflow==2.0.
pip install tensorflow==2.0

Python Error : No module named pkg_resources

I would like to use Python3.7 on MacOS
I already Python 2.7 version.
I created an alias on .bash_profile, alias python="/usr/local/bin/python3.7" then source ~/.bash_profile.
So I deleted Python2.7 to /usr/local/lib/
Now, when I try to execute pip install PySide2, I have an error :
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
I think this error has happened since I deleted Python2.7
Someone can help me to resolve my error ?
Thank you !
pyinstaller 3.6 is incompatible with setuptools 45.1.0 on python 3.7.*, should be downgraded to 45.0.0
pip install setuptools==45.0.0
can also be fixed with passing/adding hidden_imports 'pkg_resources.py2_warn' to pyinstaller spec
Issue and solutions are tracked here: https://github.com/pypa/setuptools/issues/1963
I found solution from here.
In my case, I open hook-pkg_resources.py file from the following directory:
~/.local/lib/python3.6/site-packages/PyInstaller/hooks/
After that I added this line of code:
hiddenimports.append('pkg_resources.py2_warn')
between these two lines of code:
hiddenimports = collect_submodules('pkg_resources._vendor')
and
excludedimports = ['__main__']
After that, I ran PyInstaller again and the resulted executable worked like charm.
This is caused because of a broken setuptools package, you just need to reinstall it.
For most operating systems: pip install setuptools
Linux: apt-get install python-setuptools or yum install python-setuptools
Stumbled uppon this answer first on google when searching for this error code, so for future reference ill just leave a link to this issue that solved my problem:
https://stackoverflow.com/a/59979390/10565375
tldr:
pyinstaller --hidden-import=pkg_resources.py2_warn example.py

Installing PIP Python 3.6.3 Ubuntu 16.04 Zlib Not Available, But It's Installed

I'm trying to follow this tutorial on installing Python 3.6.3 and PIP with virtual environments, but when I get to sudo python3.6 get-pip.py I get the error
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
but I have zlib1g-dev installed and don't know how to fix this problem. I've googled a lot and tried reinstalling, but haven't had any success.
Sorry to start a new question, but I did not have enough Karma to comment on the other one. Any help would be greatly appreciated.
Update: I ended up installing everything from source instead of using any packages and it seems to be working. I was not able to solve the problem, but found an alternative way to get things working.
For pip to work, Python needs to be linked to the zlib library when Python itself is installed. It appears that either zlib was not installed when you installed Python, or at least that the Python installer couldn't locate it. To help it along, you may issue the following before installing Python. In bash syntax,
zlib_lib="/usr/lib32"
zlib_inc="/usr/include"
export CPPFLAGS="-I${zlib_inc} ${CPPFLAGS}"
export LD_LIBRARY_PATH="${zlib_lib}:${LD_LIBRARY_PATH}"
export LDFLAGS="-L${zlib_lib} -Wl,-rpath=${zlib_lib} ${LDFLAGS}"
Here I've assumed that zlib is installed under /usr/lib32 and /usr/include/. To check this, look for the libz.so.1 file in the "lib" directory and the zlib.h file in the "inc" directory. If you find them somewhere else, simply change zlib_lib and zlib_inc accordingly.
IF you have different versions of Python installed it is likely the install is on another version. for example. I have pyperclip in 3.6.3 32bit version, but I an not access it in 3.6.3 64bit or 3.7.2dev.

Problems importing python-Xlib

I installed a new module and it appears as if one of its dependencies was not already installed. The module is called Xlib.display.
Here is the error message I received:
from Xlib.display import Display
ImportError: No module named Xlib.display
Where can I find this module that I am apparently lacking? Google yielded no leads.
"Edit: I already have that sourceforge module downloaded but I still get the same results.
Please try.
This shall install Xlib
sudo apt-get install python-xlib
Then you can check
>>from Xlib.display import Display
To install PyMouse if you want to control and capture mouse events please use:
sudo easy_install https://github.com/pepijndevos/PyMouse/zipball/master
Below worked for me!
pip install python3_xlib
I have also used pyuserinput for automation which requires this.
I was having the same problem, but the solutions above didn't work for me. Since I had installed python through the anaconda package, when I used:
sudo apt-get install python-xlib
Xlib was still undetectable by python2. The solution in my case was to use:
anaconda search -t conda python-xlib
Then find the package from the anaconda api, mine was erik/python-xlib. Install it using:
conda install --channel https://conda.anaconda.org/erik python-xlib
Then it worked.
On Debian systems install python-xlib.
On other systems there's a high probability that the package carries the same name.
I don't think the Xlib library works in Python 3.
Source:
Requirements
The Python X Library requires Python 1.5.2 or newer. It has been tested to various extents with Python 1.5.2 and 2.0 through 2.6.
I honestly cant explain why this works... but here is the command that got it working for me.
sudo apt-get install python3-xlib
Should not work because xlib apparently does not work with python 3.x, but everything installed alright, so I'm not complaining!
I was looking for the same answer, however after some more digging it seems that XCB (X protocol C-language Binding) will obsolete Xlib in general. From the XCB website:
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.
Fortunately there are python bindings available as python-xpyb in apt or xpyb on PyPi. I've not gotten that far in my project so I haven't tested if this works with Python3, but this is probably the way to go and the proper place to file any Python3 support bugs if necessary.
Scenario:
I was trying to use screenshot functionalities of pyautogui package. I was getting this error:
Traceback (most recent call last):
File "test_screenshot.py", line 1, in <module>
import pyautogui
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/__init__.py", line 152, in <module>
from . import _pyautogui_x11 as platformModule
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/_pyautogui_x11.py", line 7, in <module>
from Xlib.display import Display
ModuleNotFoundError: No module named 'Xlib'
Python code (test_screenshot.py):
import pyautogui
img = pyautogui.screenshot('test.png')
Environment:
Ubuntu 16.04 (LTS)
conda 4.5.11
Python 3.7 (Miniconda)
requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
PyTweening==1.0.3
Solution:
I installed python-xlib package in the conda environment using:
pip install python-xlib
Now test_screenshot.py is running without any error.
Updated requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
python-xlib==0.25
PyTweening==1.0.3
six==1.12.0

Categories

Resources