Python Forum
How Do I Get the IDE to Find My Imports
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How Do I Get the IDE to Find My Imports
#6
I have a .py program that runs using Python 2.7 but fails in Python 3.7.2.
It fails at the first import statement.
I started asking for help in thread:
https://python-forum.io/Thread-How-Do-I-...My-Imports
I started to wander around too much in that thread and I have tried many things since the last post.
I am pursuing the potential problem outlined in the title of this post. I simplified the program from that post. The one I am trying to run is below. If I run it with python 2.7 it runs fine. If I run it with python 3.7.2 the window opens then closes. If I load it into IDLE (python 3.7 version) and try to run it I get:
"Traceback (most recent call last):
File "(long path removed)gnuradio\gr\__init__.py", line 37, in <module>
from runtime_swig import *
ModuleNotFoundError: No module named 'runtime_swig'

(lots more error message removed)

It looks like "from gnuradio import gr" causes it to go to __init__.py which then has a step at line 37 which says "from runtime_swig import *" however gr desn't have runtime_swig. It has runtime_swig.py, runtime_swig.pyc, and runtime_swig.pyo.

Somehow python 2.7 doesn't mind this but python 3.7 does.
Any ideas?

from gnuradio import gr
from gnuradio import audio
from gnuradio import analog

class my_top_block(gr.top_block):

    def __init__(self):
        gr.top_block.__init__(self)
        sample_rate = 32000
        ampl = 0.1

        src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl)
        src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl)
        dst = audio.sink(sample_rate, "")
        self.connect(src0, (dst, 0))
        self.connect(src1, (dst, 1))


if __name__ == '__main__':

    try:

        my_top_block().run()

    except [[KeyboardInterrupt]]:

        pass
Reply


Messages In This Thread
How Do I Get the IDE to Find My Imports - by petec - Feb-17-2019, 06:19 PM
Code Runs With Python 2.7 But Not Python 3.7.2 - by petec - Feb-19-2019, 04:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Imports that work with Python 3.8 fail with 3.9 and 3.10 4slam 1 2,630 Mar-11-2022, 01:50 PM
Last Post: snippsat
  Imports in my first package cuppajoeman 1 1,978 Jun-28-2021, 09:06 AM
Last Post: snippsat
  script with imports works but pytest gives "ModuleNotFoundError"? Hpao 0 1,589 Jun-27-2021, 08:30 PM
Last Post: Hpao
  Help wanted with python imports petros21 3 2,621 Apr-07-2021, 07:16 PM
Last Post: snippsat
Question How to include Modules not found (conditional imports) in my setup.py when I want to cff 0 3,853 Mar-17-2021, 11:57 AM
Last Post: cff
  threading across imports Nickd12 2 2,182 Nov-09-2020, 01:59 AM
Last Post: Nickd12
  refreshing imports seandepagnier 4 2,776 Sep-20-2020, 11:51 PM
Last Post: seandepagnier
  Multimode imports fine as script but not after compiling into exe chesschaser 0 2,436 Aug-13-2020, 01:28 PM
Last Post: chesschaser
  absolute imports between folders mikisDW 0 1,568 Aug-05-2020, 12:26 PM
Last Post: mikisDW
  Understanding the concept ( Modules , imports ) erfanakbari1 1 2,230 Nov-25-2019, 01:59 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020