Attribute error while executing python script
Hi i am a student and working on GNU..I have a python code which i want to run in GNU radio companion but i am unable to search for the right block to execute that code...can anyone help me with that??When I execute the same python code(not in GNU), I get the following error: AttributeError: 'top_block_sptr' object has no attribute 'wxgui_' If anyone knows about this,plz send a mail to [email protected] in advance..the code is as shown: #!/usr/bin/env pythonfrom gnuradio import blocksfrom gnuradio import eng_notationfrom gnuradio import grfrom gnuradio import uhd#from gnuradio import windowfrom gnuradio.eng_option import eng_option#from gnuradio.gr import firdesfrom gnuradio.wxgui import formsfrom gnuradio.wxgui import waterfallsink2from grc_gnuradio import wxgui as grc_wxguifrom optparse import OptionParserimport wx class top_block(grc_wxgui.top_block_gui): def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ## # Variables ### ### self.variable_slider_1 = variable_slider_1 = 32 self.variable_slider_0 = variable_slider_0 = 0 self.samp_rate = samp_rate = 21e6 self.gain = gain = variable_slider_1 self.delay_length = delay_length= variable_slider_0 ## # Blocks ## self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Output Waterfall Plot", ) self.GridAdd(self.wxgui_waterfallsink2_0_0.win, 0, 10, 10, 10) self.wxgui_ waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Input Waterfall Plot", ) self.GridAdd(self.wxgui_waterfallsink2_0.win, 0, 0, 10, 10) _variable_slider_1_sizer = wx.BoxSizer(wx.VERTICAL) self._variable_slider_1_text_box = forms.text_box( parent=self.GetWin(), sizer=_variable_slider_1_sizer, value=self.variable_slider_1, callback=self.set_variable_slider_1, label="Output Gain", converter=forms.float_converter(), proportion=0, ) self._variable_slider_1_slider = forms.slider( parent=self.GetWin(), sizer=_variable_slider_1_sizer, value=self.variable_slider_1, callback=self.set_variable_slider_1, minimum=0, maximum=32, num_steps=31, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_variable_slider_1_sizer, 12, 10, 1, 9) _variable_sl ider_0_sizer = wx.BoxSizer(wx.VERTICAL) self._variable_slider_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_variable_slider_0_sizer, value=self.variable_slider_0, callback=self.set_variable_slider_0, label="Delay Length", converter=forms.int_converter(), proportion=0, ) self._variable_slider_0_slider = forms.slider( parent=self.GetWin(), sizer=_variable_slider_0_sizer, value=self.variable_slider_0, callback=self.set_variable_slider_0, minimum=0, maximum=71, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_variable_slider_0_sizer, 10, 10, 1, 9) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.28e9, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args =uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(2.28e9, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.gr_file_source_0_0 = gr.file_source( gr.sizeof_gr_complex*1,"/home/ubuntu/radar-rx3.capture", True) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1
Re: Martijn Faassen: The Call of Python 2.8
On 2014.04.15 20:21, Steven D'Aprano wrote: > On Tue, 15 Apr 2014 17:32:57 -0500, Andrew Berg wrote: > >> On 2014.04.15 17:18, Ned Batchelder wrote: >>> Yeah, that's the wrong way to do it, and they shouldn't have done that. >>> "python" needs to mean Python 2.x for a long time. >> Or maybe explicit is better than implicit: >> >> # python >> zsh: command not found: python >> # which python2.7 >> /usr/local/bin/python2.7 >> # which python3.4 >> /usr/local/bin/python3.4 > > If you really meant that, you would have typed "/usr/bin/which2.16 > python" (or whatever the location and version of which on your system). Are you sure about that? # which which which: shell built-in command Unless I'm forgetting some more explicit way of calling a command built into the shell. -- CPython 3.4.0 | Windows NT 6.2.9200 / FreeBSD 10.0 -- https://mail.python.org/mailman/listinfo/python-list
Re: Martijn Faassen: The Call of Python 2.8
On Wed, Apr 16, 2014 at 5:32 PM, Andrew Berg wrote: >> If you really meant that, you would have typed "/usr/bin/which2.16 >> python" (or whatever the location and version of which on your system). > Are you sure about that? > # which which > which: shell built-in command > Unless I'm forgetting some more explicit way of calling a command built into > the shell. Hmm, interesting. That's not the case for me: rosuav@sikorsky:~$ which which /usr/bin/which Debian Wheezy. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Martijn Faassen: The Call of Python 2.8
On Wednesday, April 16, 2014 1:02:00 PM UTC+5:30, Andrew Berg wrote: > On 2014.04.15 20:21, Steven D'Aprano wrote: > > > On Tue, 15 Apr 2014 17:32:57 -0500, Andrew Berg wrote: > > > > > >> On 2014.04.15 17:18, Ned Batchelder wrote: > > >>> Yeah, that's the wrong way to do it, and they shouldn't have done that. > > >>> "python" needs to mean Python 2.x for a long time. > > >> Or maybe explicit is better than implicit: > > >> > > >> # python > > >> zsh: command not found: python > > >> # which python2.7 > > >> /usr/local/bin/python2.7 > >> # which python3.4 > >> /usr/local/bin/python3.4 > > If you really meant that, you would have typed "/usr/bin/which2.16 > > python" (or whatever the location and version of which on your system). > > Are you sure about that? > # which which > which: shell built-in command > Unless I'm forgetting some more explicit way of calling a command built into > the shell. Not out here: $ which which /usr/bin/which $ ls -l /usr/bin/which lrwxrwxrwx 1 root root 10 Jul 28 2013 /usr/bin/which -> /bin/which Though there is no evidence of which-versionitis which is what Steven is implying?? -- https://mail.python.org/mailman/listinfo/python-list
Re: Attribute error while executing python script
On Wed, Apr 16, 2014 at 5:45 PM, ali hanif wrote: > Hi i am a student and working on GNU..I have a python code which i want to > run in GNU radio companion but i am unable to search for the right block to > execute that code...can anyone help me with that??When I execute the same > python code(not in GNU), I get the following error: > > AttributeError: 'top_block_sptr' object has no attribute 'wxgui_' > > If anyone knows about this,plz send a mail to [email protected] > in advance..the code is as shown: Several points. I'll get to the one that you asked about. Firstly, please don't ask us to send you direct mail. I'm letting you off on that one and cc'ing you, but a lot of people won't. If you want a response, read the newsgroup/mailing list; that's what participation means. (There are a few lists where cc'ing is the convention, so you don't have to subscribe to hear the responses. This is not normal for mailing lists, and definitely not for newsgroups, so it's safer to assume you have to join.) Secondly: "GNU" is a project and an operating system, not a particular program. See http://www.gnu.org/ for more info. You're talking about "GNU Radio Companion", which may be either http://gnuradio.org/redmine/projects/gnuradio/wiki or http://gnuradio.org/redmine/projects/gnuradio/wiki/GNURadioCompanion and is not really clear. Posting a link to what you're talking about would help enormously. Thirdly: When you get an error from Python, it comes with a full traceback, pinpointing the failing line. Copy and paste the entire traceback, not just the final line, as it helps us significantly. (But in this case, I did figure out what was going on.) Finally, you'll find it a lot easier to debug programs if you cut the problem code down. Check out http://www.sscce.org/ for more info on that. Often you'll find the problem yourself as you cut the code down; if not, you can at least post a short, simple snippet, which we can more easily debug. (Note that sometimes a problem really does depend on the size of the code. I've had some of these. But then you can still post your results: "deleting any line from this code prevents the bug from happening".) > self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( > self.GetWin(), > baseband_freq=0, > dynamic_range=100, > ref_level=0, > ref_scale=2.0, > sample_rate=samp_rate, > fft_size=512, > fft_rate=15, > average=False, > avg_alpha=None, > title="Output Waterfall Plot", > ) The layout here is what's tripping you up. Either your mailer has destroyed structure, or this is almost unreadably tangled. And it results in this next problem: > self.wxgui_ > waterfallsink2_0 = waterfallsink2.waterfall_sink_c( > self.GetWin(), > baseband_freq=0, > dynamic_range=100, > ref_level=0, > ref_scale=2.0, > sample_rate=samp_rate, > fft_size=512, > fft_rate=15, > average=False, > avg_alpha=None, > title="Input Waterfall Plot", > ) You've broken this in a place that doesn't work. The traceback points you exactly to the failing line, and that's where the problem exists. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Martijn Faassen: The Call of Python 2.8
On Wed, 16 Apr 2014 02:32:00 -0500, Andrew Berg wrote: > On 2014.04.15 20:21, Steven D'Aprano wrote: >> On Tue, 15 Apr 2014 17:32:57 -0500, Andrew Berg wrote: >> >>> On 2014.04.15 17:18, Ned Batchelder wrote: Yeah, that's the wrong way to do it, and they shouldn't have done that. "python" needs to mean Python 2.x for a long time. >>> Or maybe explicit is better than implicit: >>> >>> # python >>> zsh: command not found: python >>> # which python2.7 >>> /usr/local/bin/python2.7 >>> # which python3.4 >>> /usr/local/bin/python3.4 >> >> If you really meant that, you would have typed "/usr/bin/which2.16 >> python" (or whatever the location and version of which on your system). > Are you sure about that? > # which which > which: shell built-in command > Unless I'm forgetting some more explicit way of calling a command built > into the shell. I've tried it on two different systems: steve@runes:~$ which which /usr/bin/which although I see you are running as root: steve@runes:~$ su - Password: root@runes:~# which which /usr/bin/which Nope, that makes no difference. In any case, you're missing my point, which is not *where* the which binary lives, but the fact that you're calling some specific version, located in some specific place (even if that place is a virtual place inside the shell) implicitly rather than explicitly. Which is usually (but not always!) what we want for an interactive shell. Who wants to be typing out explicit paths to versioned binaries *all the time*? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Martijn Faassen: The Call of Python 2.8
On 2014.04.16 03:02, Chris Angelico wrote: > Hmm, interesting. That's not the case for me: > > rosuav@sikorsky:~$ which which > /usr/bin/which That's because bash either does not have a builtin which or it is not enabled by default. I switched to zsh a while ago. I do still, of course, have a system which, which is at /usr/bin/which, and which is the which that a shell which does not have a builtin which will use. -- CPython 3.4.0 | Windows NT 6.2.9200 / FreeBSD 10.0 -- https://mail.python.org/mailman/listinfo/python-list
Web Designing Training Institutes in Hyderabad-Acewebacademy
For professional courses in web designing and development at an affordable price choose Ace web academy one of the best web designing institutes in Hyderabad. Call: 7660-966-660. -- https://mail.python.org/mailman/listinfo/python-list
subprocess help
Hello, I'm having some sort of 'problem' when using subprocess calls. This is the code snipet that i am using: capture_server1 = '''xvfb-run --auto-servernum ... ''' server1_download = subprocess.Popen(shlex.split(capture_server1),stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out_s1, err_s1 = server1_download.communicate() time.sleep(2) capture_server2 = '''xvfb-run --auto-servernum ''' server2_download = subprocess.Popen(shlex.split(capture_server2), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out_s2, err_s2 = server2_download.communicate() The problem is the following: - The program runs in a loop, where subprocess is called - It runs for X days, sometimes 3 days, sometimes 5 days - After that i get the following exception: File "/usr/lib/python2.7/subprocess.py", line 1091, in pipe_cloexec r, w = os.pipe() OSError: [Errno 24] Too many open files How can i reproduce this on a local machine, and how to make sure that i wont have any errors like this? P.S. Version 2.7 is used with this program -- https://mail.python.org/mailman/listinfo/python-list
Re: subprocess help
On Wed, Apr 16, 2014 at 8:47 PM, Влатко Станковиќ wrote: > capture_server1 = '''xvfb-run --auto-servernum ... ''' > server1_download = subprocess.Popen(shlex.split(capture_server1) Separate to your actual problem: Is there a reason for splitting like that, rather than simply using a list of separate arguments? That would be a lot safer and easier; no going through the hassles of quoting and splitting. Your exact problem is likely to be due to unclosed files. I don't know enough about .communicate() to know whether it closes everything immediately or not, but it looks like you're progressively opening more and more and more pipes. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: subprocess help
On Wed, 16 Apr 2014 12:47:03 +0200, Влатко Станковиќ wrote: > Hello, > I'm having some sort of 'problem' when using subprocess calls. This is > the code snipet that i am using: > > capture_server1 = '''xvfb-run --auto-servernum ... ''' > server1_download = subprocess.Popen(shlex.split(capture_server1), > stdin=subprocess.PIPE, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > > out_s1, err_s1 = server1_download.communicate() > time.sleep(2) What's the difference between the server1 code (shown above) and the server2 code (not shown, but identical as far as I can tell)? [...] > The problem is the following: > - The program runs in a loop, where subprocess is called - It runs for X > days, sometimes 3 days, sometimes 5 days - After that i get the > following exception: > > File "/usr/lib/python2.7/subprocess.py", line 1091, in pipe_cloexec r, w > = os.pipe() > OSError: [Errno 24] Too many open files You have to identify what files are remaining open. What does the xvfb- run process do? What are the rest of the arguments? My guess is that, depending on the arguments, sometimes xvfb-run leaves files open even after the process terminates. You should monitor the open files with lsof which is available on most Linux systems. I don't know how to do that on other operating systems. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Tutorials for Reorganizing Spreadsheet Data
Hello, I'm a high school physics teacher and while I've played with Python enough to make a rock paper scissors program or animation of a bouncing ball (with air resistance!), I've never used it to work with data from a spreadsheet. I have a large spreadsheet with a number of different student responses to a weekly prompt in various cells depending on which question they chose to answer. I'd like to organize these responses into something that make it easy for students to look back through their responses over time, and see how they've changed. This is obviously possible in Python, but I don't know where to begin learning the details of what I'll need to know to build it. Can anyone give me a specific recommendation of tutorials where I might begin? Thanks! Joe -- https://mail.python.org/mailman/listinfo/python-list
Re: Tutorials for Reorganizing Spreadsheet Data
On Apr 16, 2014 9:55 AM, wrote: > > Hello, I'm a high school physics teacher and while I've played with Python enough to make a rock paper scissors program or animation of a bouncing ball (with air resistance!), I've never used it to work with data from a spreadsheet. > > I have a large spreadsheet with a number of different student responses to a weekly prompt in various cells depending on which question they chose to answer. I'd like to organize these responses into something that make it easy for students to look back through their responses over time, and see how they've changed. > > This is obviously possible in Python, but I don't know where to begin learning the details of what I'll need to know to build it. Can anyone give me a specific recommendation of tutorials where I might begin? > The package xlrd will read your Excel files > Thanks! > > Joe > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Tutorials for Reorganizing Spreadsheet Data
On 4/16/2014 9:50 AM, [email protected] wrote: Hello, I'm a high school physics teacher and while I've played with Python enough to make a rock paper scissors program or animation of a bouncing ball (with air resistance!), I've never used it to work with data from a spreadsheet. I have a large spreadsheet with a number of different student responses to a weekly prompt in various cells depending on which question they chose to answer. I'd like to organize these responses into something that make it easy for students to look back through their responses over time, and see how they've changed. This is obviously possible in Python, but I don't know where to begin learning the details of what I'll need to know to build it. Can anyone give me a specific recommendation of tutorials where I might begin? Is your spreadsheet actually on sheets (paper) or in a program? If the latter, you should be about to output the data as a 'comma-separated variable' (csv) file and read it in python with the csv module. If you want to work with the data directly in the spreadsheet file, the details depend on the OS and program. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
import serial failure
I have installed both Python 2.7 AND Python 3.3 and the corresponding pyserial
files from
ihttps://pypi.python.org/packages/any/p/pyserial/pyserial-2.7.win32.exe#md5=21555387937eeb79126cde25abee4b35n
my
for 2.7
When I look in my Python27/Lib/site-packages/serial folder I see
package files
but when I run a program using import serial, I get an error
Traceback (most recent call last):
File "C:\Users\Jahree\serial.py", line 2, in
import serial
File "C:\Users\Jahree\serial.py", line 5, in
ser = serial.Serial(
AttributeError: 'module' object has no attribute 'Serial'
I'm guessing there is a path not set correctly - I'M STUCK
Please help.
Thanks
ps: the following is serial.py file I'm using for testing.
import time
import serial
# configure the serial connections (the parameters differs on the device you
are connecting to)
ser = serial.Serial(
port='/dev/ttyUSB1',
baudrate=19200,
parity=serial.PARITY_ODD,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.SEVENBITS
)
ser.open()
ser.isOpen()
print('Enter your commands below.\r\nInsert "exit" to leave the application.')
input=1
while 1 :
# get keyboard input
input = raw_input(">> ")
input = input(">> ")
if input == 'exit':
ser.close()
exit()
else:
# send the character to the device
# (note that I happend a \r\n carriage return and line feed to the
characters - this is requested by my device)
ser.write(input + '\r\n')
out = ''
# let's wait one second before reading output (let's give device time
to answer)
time.sleep(2)
while ser.inWaiting() > 0:
out += ser.read(4)
if out != '':
print(">>" ,out)
--
https://mail.python.org/mailman/listinfo/python-list
Re: import serial failure
On Wed, Apr 16, 2014 at 12:56 PM, J W Burton wrote: > I have installed both Python 2.7 AND Python 3.3 and the corresponding > pyserial files from > > ihttps://pypi.python.org/packages/any/p/pyserial/pyserial-2.7.win32.exe#md5=21555387937eeb79126cde25abee4b35n > my > > for 2.7 > > When I look in my Python27/Lib/site-packages/serial folder I see > package files > > but when I run a program using import serial, I get an error > Traceback (most recent call last): > File "C:\Users\Jahree\serial.py", line 2, in > import serial > File "C:\Users\Jahree\serial.py", line 5, in > ser = serial.Serial( > AttributeError: 'module' object has no attribute 'Serial' > > I'm guessing there is a path not set correctly - I'M STUCK > > Please help. > > Thanks > > ps: the following is serial.py file I'm using for testing. > > import time > import serial Your file is named serial.py, so "import serial" in that file will try to import itself. You can see this in the traceback you posted, everything is coming from "C:\Users\Jahree\serial.py". Rename your serial.py and things should work as expected. Hope this helps, -- Zach -- https://mail.python.org/mailman/listinfo/python-list
Re: import serial failure
J W Burton wrote: > I have installed both Python 2.7 AND Python 3.3 and the corresponding > pyserial files from > > ihttps://pypi.python.org/packages/any/p/pyserial/pyserial-2.7.win32.exe#md5=21555387937eeb79126cde25abee4b35n > my > > for 2.7 > > When I look in my Python27/Lib/site-packages/serial folder I see > package files > > but when I run a program using import serial, I get an error > Traceback (most recent call last): > File "C:\Users\Jahree\serial.py", line 2, in > import serial > File "C:\Users\Jahree\serial.py", line 5, in > ser = serial.Serial( > AttributeError: 'module' object has no attribute 'Serial' > > I'm guessing there is a path not set correctly - I'M STUCK > > Please help. > > Thanks > > ps: the following is serial.py file I'm using for testing. Your choice of filename is unfortunate ;) > import time > import serial The file is importing itself here. Rename your C:\Users\Jahree\serial.py to something unique, say C:\Users\Jahree\myserial.py delete C:\Users\Jahree\serial.pyc and everything should be OK. -- https://mail.python.org/mailman/listinfo/python-list
[ANN] JOSE
Hi all, jose is a Python Javascript Object Signing and Encryption (JOSE, https://datatracker.ietf.org/wg/jose/charter/) implementation, intended to support token-based authentication. This library implements JWS and JWEs along with a subset of the encryption/authentication algorithms recommended by the JOSE framework. Code: https://github.com/Demonware/jose Docs: http://jose.readthedocs.org/en/latest PyPI: https://pypi.python.org/pypi/jose -- Demian Brecht http://demianbrecht.github.com -- https://mail.python.org/mailman/listinfo/python-list
