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
#1
I can't seem to get an IDE to find my imports.
I have tried IDLE and Visual Basic (Note I have used Visual Basic to write a few python programs quite successfully)

I have a python program as a file on my windows desktop.
The name is tutorial_three_1.py
If I double click it, it runs fine.
If I open it in either IDLE or Visual Basic I can't debug it because IDE reports:
"Traceback (most recent call last):
File "C:\Users\Pete\Desktop\tutorial_three_1.py", line 9, in <module>
from gnuradio import analog
File "C:\Program Files (x86)\AAours(x86)\Utilities\SDR\GNURadio-3.7\lib\site-packages\gnuradio\analog\__init__.py", line 33, in <module>
from analog_swig import *
ModuleNotFoundError: No module named 'analog_swig'
"

And Visual Basic reports:
"Unable to resolve 'gnuradio'. IntelliSense may be missing for this module".

I am new to python but I understand the program is just a script so when it runs it somehow finds the imports but in an IDE they are not found. The code is below. If you run it you should hear two tones through your sound card. 350 Hz and 440 Hz.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Tutorial Three 1
# Generated: Sat Feb 16 15:56:06 2019
##################################################

from gnuradio import analog
from gnuradio import audio
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser


class tutorial_three_1(gr.top_block):

    def __init__(self):
        gr.top_block.__init__(self, "Tutorial Three 1")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_SQR_WAVE, 350, 0.1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 440, 0.1, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.audio_sink_0, 1))

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate
        self.analog_sig_source_x_1.set_sampling_freq(self.samp_rate)
        self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)


def main(top_block_cls=tutorial_three_1, options=None):

    tb = top_block_cls()
    tb.start()
    try:
        raw_input('Press Enter to quit: ')
    except EOFError:
        pass
    tb.stop()
    tb.wait()


if __name__ == '__main__':
    main()
Reply


Messages In This Thread
How Do I Get the IDE to Find My Imports - by petec - Feb-17-2019, 06:19 PM

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,600 Mar-11-2022, 01:50 PM
Last Post: snippsat
  Imports in my first package cuppajoeman 1 1,964 Jun-28-2021, 09:06 AM
Last Post: snippsat
  script with imports works but pytest gives "ModuleNotFoundError"? Hpao 0 1,574 Jun-27-2021, 08:30 PM
Last Post: Hpao
  Help wanted with python imports petros21 3 2,571 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,831 Mar-17-2021, 11:57 AM
Last Post: cff
  threading across imports Nickd12 2 2,157 Nov-09-2020, 01:59 AM
Last Post: Nickd12
  refreshing imports seandepagnier 4 2,754 Sep-20-2020, 11:51 PM
Last Post: seandepagnier
  Multimode imports fine as script but not after compiling into exe chesschaser 0 2,419 Aug-13-2020, 01:28 PM
Last Post: chesschaser
  absolute imports between folders mikisDW 0 1,547 Aug-05-2020, 12:26 PM
Last Post: mikisDW
  Understanding the concept ( Modules , imports ) erfanakbari1 1 2,199 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