Feb-17-2019, 06:19 PM
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.
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()