Bug 1383513

Summary: ImportError: cannot import name Event
Product: [Fedora] Fedora Reporter: Robert Bost <bostrt>
Component: rtlsdr-scannerAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: jskarvad
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rtlsdr-scanner-1.0.22497.10311-1.fc25 rtlsdr-scanner-1.0.22497.10311-1.fc24 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-18 11:30:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Robert Bost 2016-10-10 21:43:19 UTC
Description of problem:
Cannot start rtlsdr-scanner app


Version-Release number of selected component (if applicable):
rtlsdr-scanner-1.0.22298.18049-2.fc24.noarch


How reproducible: Always.


Steps to Reproduce:
# rtlsdr_scan 
Traceback (most recent call last):
  File "/usr/bin/rtlsdr_scan", line 52, in <module>
    from cli import Cli
  File "/usr/lib/python2.7/site-packages/rtlsdr-scanner/cli.py", line 37, in <module>
    from events import Event
ImportError: cannot import name Event

Comment 1 Jaroslav Škarvada 2016-10-12 09:14:09 UTC
Hmm, strange, but I am unable to reproduce. I tried on two different machines. The events.py is installed by the rtlsdr-scanner package and the Event class is there and I can also run the scanner without problem. Maybe your rtlsdr-scanner installation is damaged, try:
$ rpm -qV rtlsdr-scanner

or maybe, there is an events.py from different package that loads instead (but this would be even more strange), please provide output of the:

$ python -v /usr/bin/rtlsdr_scan

Comment 2 Robert Bost 2016-10-12 13:06:31 UTC
That was it, there's another package called events:

# python -v /usr/bin/rtlsdr_scan 2>&1 | grep events
import events # directory /usr/lib/python2.7/site-packages/events
# /usr/lib/python2.7/site-packages/events/__init__.pyc matches /usr/lib/python2.7/site-packages/events/__init__.py
import events # precompiled from /usr/lib/python2.7/site-packages/events/__init__.pyc
# /usr/lib/python2.7/site-packages/events/events.pyc matches /usr/lib/python2.7/site-packages/events/events.py
import events.events # precompiled from /usr/lib/python2.7/site-packages/events/events.pyc
    from events import Event
# cleanup[1] events
# cleanup[1] events.events

# sudo pip uninstall events
Uninstalling Events-0.2.1:
[...]

# rtlsdr_events
<gui launches>

Is there a way to allow the Events package to be installed from pip alongside rtlsdr-scanner and its internal events module?

Comment 3 Jaroslav Škarvada 2016-10-12 14:18:29 UTC
(In reply to Robert Bost from comment #2)
> That was it, there's another package called events:
> 
> # python -v /usr/bin/rtlsdr_scan 2>&1 | grep events
> import events # directory /usr/lib/python2.7/site-packages/events
> # /usr/lib/python2.7/site-packages/events/__init__.pyc matches
> /usr/lib/python2.7/site-packages/events/__init__.py
> import events # precompiled from
> /usr/lib/python2.7/site-packages/events/__init__.pyc
> # /usr/lib/python2.7/site-packages/events/events.pyc matches
> /usr/lib/python2.7/site-packages/events/events.py
> import events.events # precompiled from
> /usr/lib/python2.7/site-packages/events/events.pyc
>     from events import Event
> # cleanup[1] events
> # cleanup[1] events.events
> 
> # sudo pip uninstall events
> Uninstalling Events-0.2.1:
> [...]
> 
> # rtlsdr_events
> <gui launches>
> 
> Is there a way to allow the Events package to be installed from pip
> alongside rtlsdr-scanner and its internal events module?

Thanks for info.

Mixing distribution RPM with 3rd party package manager (PIP) is IMHO unsupported.

Events is not provided by any Fedora RPM, so there is nothing to fix:
$ dnf provides '/usr/lib/python2.7/site-packages/events/*'

I think the main problem is that the 'events' you use imports events.py in its __init__.py. Why it does it? But this is really not Fedora bug. The rtlsdr-scanenr package use correct import which should correctly utilize loading paths, i.e. there is nothing to fix.

Comment 4 Jaroslav Škarvada 2016-10-12 14:22:15 UTC
(In reply to Jaroslav Škarvada from comment #3)
> I think the main problem is that the 'events' you use imports events.py in
> its __init__.py. Why it does it? But this is really not Fedora bug. The
> rtlsdr-scanenr package use correct import which should correctly utilize
> loading paths, i.e. there is nothing to fix.

Incorrect, hmm, interesting that it doesn't work with the default paths, I will check it.

Comment 6 Jaroslav Škarvada 2016-10-12 14:27:02 UTC
So the default behaviour changed in Python 2.7 to absolute imports. While there is currently no conflict at the moment with distribution packages it maybe worth to fix it, reopening.

Comment 7 Jaroslav Škarvada 2016-10-13 14:27:10 UTC
Upstream pull request not only fixing this bug, but also trying to do proper modularization of the code:
https://github.com/EarToEarOak/RTLSDR-Scanner/pull/28

Comment 8 Fedora Update System 2016-10-14 03:20:33 UTC
rtlsdr-scanner-1.0.22497.10311-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-f5f29a57d5

Comment 9 Fedora Update System 2016-10-14 04:55:41 UTC
rtlsdr-scanner-1.0.22497.10311-1.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-ce05cb672d

Comment 10 Fedora Update System 2016-10-18 11:30:22 UTC
rtlsdr-scanner-1.0.22497.10311-1.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2016-10-22 07:54:53 UTC
rtlsdr-scanner-1.0.22497.10311-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.