Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'PyQt5.sip' #892

Closed
christroutner opened this issue Oct 11, 2018 · 15 comments
Closed

No module named 'PyQt5.sip' #892

christroutner opened this issue Oct 11, 2018 · 15 comments

Comments

@christroutner
Copy link

I tried following the directions in the README to build Electron Cash from source on a Ubuntu 18.04 VM. This was a new system, setup for experimenting with software.

When I got to the part where I run pyrcc5 icons.qrc -o gui/qt/icons_rc.py, I got this output:

trout@trout-wasabi:~/Electron-Cash$ pyrcc5 icons.qrc -o gui/qt/icons_rc.py
Traceback (most recent call last):
  File "/usr/local/bin/pyrcc5", line 11, in <module>
    load_entry_point('PyQt5==5.11.3', 'console_scripts', 'pyrcc5')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 480, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2693, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.6/dist-packages/PyQt5-5.11.3-py3.6-linux-x86_64.egg/PyQt5/pyrcc_main.py", line 21, in <module>
    from PyQt5.QtCore import PYQT_VERSION_STR, QDir, QFile
ModuleNotFoundError: No module named 'PyQt5.sip'
@christroutner
Copy link
Author

This is apparently a known bug in sip?
pyinstaller/pyinstaller#3630

@clifordsymack
Copy link

@christroutner this help for me #850 (comment)

I made the follows:

pip uninstall pyqt5
pip install --upgrade pyqt5

@soulofmischief
Copy link

After checking for the required dependencies using

pip3 install --user --upgrade PyQt5
pip3 install --user --upgrade PyQt5-sip

I still encounter the following error referencing a missing module named PyQt5.sip

electron-cash:91: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
[ecc] info: libsecp256k1 library not available, falling back to python-ecdsa. This means signing operations will be slower.
Traceback (most recent call last):
File "electron-cash", line 378, in
d.init_gui(config, plugins)
File "/usr/local/opt/Electron Cash-3.3.4/lib/daemon.py", line 303, in init_gui
gui = import('electroncash_gui.' + gui_name, fromlist=['electroncash_gui'])
File "/usr/local/opt/Electron Cash-3.3.4/gui/qt/init.py", line 33, in
from PyQt5.QtGui import *
ModuleNotFoundError: No module named 'PyQt5.sip'

Does someone with more knowledge in this area know how pyinstaller/pyinstaller#3630 (comment) applies to this issue with electron cash?

PyQt5.QtGui import * seems to be calling for SIP in some deprecated manner due to SIP no longer being bundled with PyQt5.

I am not able to open any version of electron-cash and cannot access my wallets so this is an urgent issue.

@cculianu
Copy link
Collaborator

Try:

pip3 install --user -I PyQt5
pip3 install --user -I PyQt5-sip

-I tells it to ignore already-installed packages and reinstall them.

PyQt5.QtGui import * seems to be calling for SIP in some deprecated manner due to SIP no longer being bundled with PyQt5.

No.. to the contrary -- sip is bundled with PyQt5 as sip.so.

@cculianu
Copy link
Collaborator

Also try the thing clifordsymack suggested:

pip uninstall pyqt5
pip install --upgrade pyqt5

@soulofmischief
Copy link

No.. to the contrary -- sip is bundled with PyQt5 as sip.so.

So does this only apply to building and not running the binaries? http://pyqt.sourceforge.net/Docs/PyQt5/installation.html#downloading-sip

I'd already tried clifordsymack's suggestion to no success. However, your tip about using -I seemed to work. Thanks a lot!

@rt121212121
Copy link

Dud PyQt5 release that should be fixed in next one if I understand correctly.

https://www.riverbankcomputing.com/pipermail/pyqt/2018-December/041211.html

@JLMoriart
Copy link

JLMoriart commented Apr 14, 2019

I had this issue; the chat that led to the resolution of the issue is below. It looks like having python3-pyqt5 installed via apt was the problem, and so uninstalling it via apt ("sudo apt remove python3-pyqt5") and then installing it with "pip3 install --user -I PyQt5" solved the problem. I'm including everything below just for reference and so that if anyone searches the same errors they can find this page.

John Moriarty, [14.04.19 16:53]
I downloaded the tar.gz, uncompressed, and ran "sudo python3 setup.py install". This seemed to install with no problems, but when I try to open electron cash via desktop integration, nothing happens. I then tried running it from the download directory with "./electron-cash", which gave the following error:

John Moriarty, [14.04.19 16:53]
Traceback (most recent call last):
File "./electron-cash", line 384, in
d.init_gui(config, plugins)
File "/home/john/Desktop/Electron Cash-4.0.1/lib/daemon.py", line 312, in init_gui
gui = import('electroncash_gui.' + gui_name, fromlist=['electroncash_gui'])
File "/home/john/Desktop/Electron Cash-4.0.1/gui/qt/init.py", line 33, in
from PyQt5.QtGui import *
ModuleNotFoundError: No module named 'PyQt5.sip'

alwaysAn0n, [14.04.19 16:53]
[In reply to John Moriarty]
Can't find the link I was looking for but if you're running into dependency issues, make sure to install the packages listed here: https://github.com/Electron-Cash/Electron-Cash#development-version

John Moriarty, [14.04.19 16:54]
But when I run "sudo apt-get install python3-pyqt5" it says "python3-pyqt5 is already the newest version (5.10.1+dfsg-1ubuntu2)."

John Moriarty, [14.04.19 16:55]
ah, didn't get as far down as the development version, will give those a shot

alwaysAn0n, [14.04.19 16:55]
Try those then report back if you're still having the same problem.

John Moriarty, [14.04.19 16:56]
I'll go ahead and delete the tar.gz and clone from the repository too

John Moriarty, [14.04.19 17:13]
Okay so I got as far as "Running unit tests"

John Moriarty, [14.04.19 17:13]
after installing tox and running it in the Electron-Cash git directory, I get the following errors:

John Moriarty, [14.04.19 17:14]
ERROR: invocation failed (exit code 1), logfile: /home/john/Electron-Cash/.tox/log/GLOB-0.log
================================== log start ===================================
File "setup.py", line 41
SyntaxError: Non-ASCII character '\xe2' in file setup.py on line 41, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

=================================== log end ====================================
ERROR: FAIL could not package project - v = InvocationError(u'/usr/bin/python setup.py sdist --formats=zip --dist-dir /home/john/Electron-Cash/.tox/dist', 1)

John Moriarty, [14.04.19 17:15]
and running "./electron-cash" still gives me the error ending in "python3 setup.py install"

alwaysAn0n, [14.04.19 17:16]
[In reply to John Moriarty]
Can you paste the whole error message?

John Moriarty, [14.04.19 17:16]
Traceback (most recent call last):
File "./electron-cash", line 388, in
d.init_gui(config, plugins)
File "/home/john/Electron-Cash/lib/daemon.py", line 323, in init_gui
gui = import('electroncash_gui.' + gui_name, fromlist=['electroncash_gui'])
File "/home/john/Electron-Cash/gui/qt/init.py", line 33, in
from PyQt5.QtGui import *
ModuleNotFoundError: No module named 'PyQt5.sip'

alwaysAn0n, [14.04.19 17:17]
Ah. Same one then

John Moriarty, [14.04.19 17:18]
oh oops, didn't actually copy the ending part for that message, my bad

John Moriarty, [14.04.19 17:18]
because terminal requires right click and I always forget

John Moriarty, [14.04.19 17:19]
I might have multiple versions of python on this machine from a bunch of other crap I've tried to get running. Might that make a difference?

alwaysAn0n, [14.04.19 17:19]
[In reply to John Moriarty]
I don't have much more help to offer sadly. Maybe stick around until @im_uname or @cculianu show up. They are the resident experts for things of this nature.

John Moriarty, [14.04.19 17:20]
On this stackoverflow page:

John Moriarty, [14.04.19 17:20]
https://stackoverflow.com/questions/51324754/python-3-6-x-pyinstaller-gives-error-no-module-named-pyqt5-sip

im_uname, [14.04.19 17:20]
ahhhhhh pyqt5 again aaahhhhhhhhhh

John Moriarty, [14.04.19 17:20]
it says "I had the same issue which is apparently a known bug due to sip now being installed separately.

pyinstaller/pyinstaller#3630

Upon creating the installer I added the line:

--hidden-import PyQt5.sip

This worked no problem."

John Moriarty, [14.04.19 17:20]
Should I try adding that line to a file somewhere? xD

John Moriarty, [14.04.19 17:21]
[In reply to im_uname]
😭

im_uname, [14.04.19 17:22]
#892

im_uname, [14.04.19 17:22]
@cculianu appimage will end our suffering right? right?

John Moriarty, [14.04.19 17:28]
trying the "-I tells it to ignore already-installed packages and reinstall them." method

John Moriarty, [14.04.19 17:28]
it'll take a while though at 80kB/s... #mobileDataForTheWin

John Moriarty, [14.04.19 17:46]
while trying "pip3 install --user -I PyQt5" I got the following error:

John Moriarty, [14.04.19 17:47]
Collecting PyQt5
Downloading https://files.pythonhosted.org/packages/98/61/fcd53201a23dd94a1264c29095821fdd55c58b4cd388dc7115e5288866db/PyQt5-5.12.1-5.12.2-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl (61.2MB)
81% |██████████████████████████▏ | 50.0MB 85kB/s eta 0:02:11
THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
PyQt5 from https://files.pythonhosted.org/packages/98/61/fcd53201a23dd94a1264c29095821fdd55c58b4cd388dc7115e5288866db/PyQt5-5.12.1-5.12.2-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl#sha256=d4e88208dfd017636e4b1f407990d0c3b6cf47afed6be4f2fb6ca887ef513e4b:
Expected sha256 d4e88208dfd017636e4b1f407990d0c3b6cf47afed6be4f2fb6ca887ef513e4b
Got 331687a0315132d0b6b92c5a1a76aabdd341e9333812a5f7c86e4fb3dbfd9e9b

im_uname, [14.04.19 17:48]
...what

John Moriarty, [14.04.19 17:49]
[In reply to im_uname]
😂😭😱

im_uname, [14.04.19 17:50]
[In reply to John Moriarty]
i suppose you already tried uninstalling and reinstalling pyqt5 via apt right?

John Moriarty, [14.04.19 17:51]
I tried it via pip and it said "Cannot uninstall requirement pyqt5, not installed"

John Moriarty, [14.04.19 17:51]
should I try apt?

im_uname, [14.04.19 17:51]
yeah give it a shot

im_uname, [14.04.19 17:51]
also try sudo pip3 install pyqt5 pyqt5-sip

im_uname, [14.04.19 17:52]
from time to time there are strange pip packages that somehow only work when installed globally

John Moriarty, [14.04.19 17:52]
"sudo pip3 install pyqt5 pyqt5-sip" gives:

John Moriarty, [14.04.19 17:53]
The directory '/home/john/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/john/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pyqt5 in /usr/local/lib/python3.6/dist-packages/PyQt5-5.11.3-py3.6-linux-x86_64.egg
Requirement already satisfied: pyqt5-sip in /usr/local/lib/python3.6/dist-packages/PyQt5_sip-4.19.13-py3.6-linux-x86_64.egg

John Moriarty, [14.04.19 17:53]
with apt, will that be "sudo apt remove —purge pyqt5"?

im_uname, [14.04.19 17:56]
[In reply to John Moriarty]
yeah, i think it should work without purge too

im_uname, [14.04.19 17:58]
[In reply to John Moriarty]
if the apt path doesn't work, give sudo pip3 install -U pyqt5 pyqt5-sip a shot

John Moriarty, [14.04.19 18:00]
sudo apt remove pyqt5
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package pyqt5

John Moriarty, [14.04.19 18:01]
"sudo pip3 install -U pyqt5 pyqt5-sip" is currently Collecting pyqt5

im_uname, [14.04.19 18:02]
[In reply to John Moriarty]
python3-pyqt5, not pyqt5

John Moriarty, [14.04.19 18:11]
oooooooooop[s

John Moriarty, [14.04.19 18:14]
Guess I'll wait to see if ... nevermind I just hit control C and canceled the "sudo pip3 install -U pyqt5 pyqt5-sip" trying to copy it xO

John Moriarty, [14.04.19 18:15]
ok so removing python3-pyqt5 was successful

John Moriarty, [14.04.19 18:15]
what should I do next?

John Moriarty, [14.04.19 18:31]
scrolling up looks like you said to reinstall using apt so I'll give that a shot

John Moriarty, [14.04.19 18:34]
reinstalled via apt with "sudo apt install python3-pyqt5" and there's not change, getting the same error:

John Moriarty, [14.04.19 18:34]
./electron-cash
Traceback (most recent call last):
File "./electron-cash", line 388, in
d.init_gui(config, plugins)
File "/home/john/Electron-Cash/lib/daemon.py", line 323, in init_gui
gui = import('electroncash_gui.' + gui_name, fromlist=['electroncash_gui'])
File "/home/john/Electron-Cash/gui/qt/init.py", line 33, in
from PyQt5.QtGui import *
ModuleNotFoundError: No module named 'PyQt5.sip'

checksum0, [14.04.19 18:36]
Install with pip

checksum0, [14.04.19 18:36]
Not apt

John Moriarty, [14.04.19 18:39]
ok so uninstalling again via apt, and then trying "pip3 install --user -I PyQt5"

JF 010, [14.04.19 18:51]
pyqt5 env issues can be a nightmare.

checksum0, [14.04.19 18:52]
Yeah, and installing ec on Debian based is a absolute pain in the ass for some reasons

im_uname, [14.04.19 18:57]
[In reply to John Moriarty]
Try this again too

John Moriarty, [14.04.19 18:57]
after apt uninstall and then installing via pip "Successfully installed PyQt5-5.12.1 PyQt5-sip-4.19.15"

John Moriarty, [14.04.19 18:58]
./electron-cash works =)

John Moriarty, [14.04.19 18:58]
and so does desktop integration =))

@cculianu
Copy link
Collaborator

Wow -- so Ubuntu package maintainers are to blame! I'm going to sticky this issue. Thanks for the follow-up!

@hieu-van
Copy link

hieu-van commented Jul 9, 2019

Installing PyQt5 from SIP would make apps that are dependent on OS-installed libraries stop working (e.g. QGIS). Is there a workaround for this?

@EchterAgo
Copy link

Best to install your dependencies in a virtualenv. In the source directory you can run this to create a virtualenv in subfolder env:

python3 -m venv env
source env/bin/activate
pip install -r contrib/requirements/requirements.txt
pip install -r contrib/requirements/requirements-binaries.txt
pip install -r contrib/requirements/requirements-hw.txt

Then you can run using ./electron-cash. Note that you have to activate the env every time before you run the app using source env/bin/activate

@hieu-van
Copy link

hieu-van commented Jul 9, 2019

Best to install your dependencies in a virtualenv. In the source directory you can run this to create a virtualenv in subfolder env:

python3 -m venv env
source env/bin/activate
pip install -r contrib/requirements/requirements.txt
pip install -r contrib/requirements/requirements-binaries.txt
pip install -r contrib/requirements/requirements-hw.txt

Then you can run using ./electron-cash. Note that you have to activate the env every time before you run the app using source env/bin/activate

Thanks! Will this be resolved in the future, or I have to do that every time firing up Electron Cash?
This is kinda a dependency conflict as far as I'm concerned

@EchterAgo
Copy link

EchterAgo commented Jul 9, 2019

If you install stuff with pip it is going to affect other apps on your system, nothing we can do about that. That is why there are virtualenvs, giving you the option to package all the specific dependencies of an app into a directory.

You should recreate the virtualenv (first 5 commands) when you switch to a new version of EC as the dependencies might have changed. source env/bin/activate needs to be run every time before running EC.

achyut3598 added a commit to achyut3598/Travel-Scheduler-Desktop that referenced this issue Jul 14, 2019
Signup is functional in the sense that it stores data in a text file. Login doesn't do anything right now. Once we have the database setup, we can decode and compare the passwords

Note:
Electron-Cash/Electron-Cash#892 Follow the solution here to fix PyQt sip issues
cculianu added a commit that referenced this issue Aug 6, 2019
…ture

This should address all the extant issues users sometimes report with
the daemon lockfile causing Electron Cash to never start up.  99% of the
issues related to this were the create_time being in the future.

Previously the daemon/lockfile mechanism would hang forever if the
lockfile's create_time was in the future. This can happen if there was a
system clock adjustment since the last run of the program and the
lockfile remained present (which the previous code didn't even ensure
would be deleted in most normal GUI uses!)

Now, we:

- Ensure the lockfile is removed if created by us using atexit.
- We no longer tolerate "connection failed" + create_time in the future:
Obviously this means there was a clock adjustment.
- We also take steps to prevent infinite hangs due to other filesystem
funny business after > 5 retries.

This commit fixes #1240, #892, #1484
cculianu added a commit to simpleledger/Electron-Cash-SLP that referenced this issue Aug 6, 2019
…ture

This should address all the extant issues users sometimes report with
the daemon lockfile causing Electron Cash to never start up.  99% of the
issues related to this were the create_time being in the future.

Previously the daemon/lockfile mechanism would hang forever if the
lockfile's create_time was in the future. This can happen if there was a
system clock adjustment since the last run of the program and the
lockfile remained present (which the previous code didn't even ensure
would be deleted in most normal GUI uses!)

Now, we:

- Ensure the lockfile is removed if created by us using atexit.
- We no longer tolerate "connection failed" + create_time in the future:
Obviously this means there was a clock adjustment.
- We also take steps to prevent infinite hangs due to other filesystem
funny business after > 5 retries.

This commit fixes Electron-Cash#1240, Electron-Cash#892, Electron-Cash#1484
@hieu-van
Copy link

For anyone that is looking for a workaround: Best to use AppImage instead.

@noman178
Copy link

Uninstalling and then reinstalling the PyQt5 works for me on PyCharm.
Use:
pip uninstall pyqt5
pip uninstall pyqt5-sip
and then reinstall again by using:
pip install pyqt5
pip install pyqt5-sip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants