connection aborted error please help to fix it

2021-08-17 Thread hi





   Sent from [1]Mail for Windows



References

   Visible links
   1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error .. Please Help

2012-12-13 Thread Dave Angel
On 12/13/2012 04:23 AM, inshu chauhan wrote:
>>
>> if-else doesn't define a loop, but each of the for statements do.
>>
>> You have defined a classification for 8 of the possible colors, leaving
>> millions of them undefined.  If the first time through the loop you
>> manage to hit one of those undefined ones, you'll have no value for
>> classification.  So you get an exception.
>>
> 
> Yes, You are right that I will hit an exception if classification doesnot
> have any value.
> But as for the colors, actually I myself have colored the image using these
> 8 colors
> but still I think in some pixels I have put more than 1 color, thats why
> different colors are being encountered.
> 
>>
>> Worse, if you manage to get past that first pixel with a valid
>> classification, then for remaining pixels, you'll be using the last
>> 'valid' classification encountered.  This is the kind of "quiet failure"
>> that programmers dread.  Something that seems to work, but isn't even
>> close.
>>
> 
> For this I put an else clause at end but is there a better way to avoid
> this kind of situation ??

Why would you want to avoid it?  It has showed you there's a bug
somewhere.  That's better than silently doing something wrong.  As
ChrisA has said, you probably should raise your own exception in the
else clause, explaining to the user that the data file is invalid, and
exactly why.


> 
>>
>> If you're going to print (to file) on each iteration through the loop
>> (except 0,0,0), you need to make sure there's always a valid value.  So
>> you need at least one more classification value, and an else clause to
>> assign it, as ChrisA pointed out.
>>
>> Do you have a reason for treating (0,0,0) specially?  When that value is
>> seen, the logic skips the print as well, since continue skips to the
>> next loop iteration.
>>
> 
> Yes , I have to skip (0,0,0), that is a kind of requirement.
>

That's fine.

>>
>> Are you really getting floating point values, or are they always going
>> to be equal to an integer?  Those if/elif statements might be a problem
>> if you ever need to compare to a value like (128.4, 255.0, 255.0).
>>
> 
> I dont have values with decimal part, All values are integer.
> 

Then why are you comparing to floats?  It'd be faster and clearer and
less typing if you just use ints.  That is of course assuming that the
values returned by image[y,x] are a tuple of ints.  You can check that
by doing something like
print [type(i) for i in color]

Is there any chance the image is 16 bits per pixel?

-- 

DaveA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error .. Please Help

2012-12-13 Thread Neil Cerutti
On 2012-12-13, inshu chauhan  wrote:
> For this I put an else clause at end but is there a better way
> to avoid this kind of situation ??

An if-elif-else structure is usually broken if you leave out the
else part. When I don't expect it to ever actually happen when
the program is working correctly it looks like this:

   else:
  raise SomeException("{} can't happen!".format(the_context))

else: raise exception constructs have saved me a lot of time.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error .. Please Help

2012-12-13 Thread Chris Angelico
On Thu, Dec 13, 2012 at 8:23 PM, inshu chauhan  wrote:
>> Are you really getting floating point values, or are they always going
>> to be equal to an integer?  Those if/elif statements might be a problem
>> if you ever need to compare to a value like (128.4, 255.0, 255.0).
>
>
> I dont have values with decimal part, All values are integer.

Find out how the tuples are actually being given to you. Floating
point values are rather annoying when it comes to comparisons. Try
printing out one of the tuples; I would hope that it has integer
values, not floats, in it.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error .. Please Help

2012-12-13 Thread inshu chauhan
>
> if-else doesn't define a loop, but each of the for statements do.
>
> You have defined a classification for 8 of the possible colors, leaving
> millions of them undefined.  If the first time through the loop you
> manage to hit one of those undefined ones, you'll have no value for
> classification.  So you get an exception.
>

Yes, You are right that I will hit an exception if classification doesnot
have any value.
But as for the colors, actually I myself have colored the image using these
8 colors
but still I think in some pixels I have put more than 1 color, thats why
different colors are being encountered.

>
> Worse, if you manage to get past that first pixel with a valid
> classification, then for remaining pixels, you'll be using the last
> 'valid' classification encountered.  This is the kind of "quiet failure"
> that programmers dread.  Something that seems to work, but isn't even
> close.
>

For this I put an else clause at end but is there a better way to avoid
this kind of situation ??

>
> If you're going to print (to file) on each iteration through the loop
> (except 0,0,0), you need to make sure there's always a valid value.  So
> you need at least one more classification value, and an else clause to
> assign it, as ChrisA pointed out.
>
> Do you have a reason for treating (0,0,0) specially?  When that value is
> seen, the logic skips the print as well, since continue skips to the
> next loop iteration.
>

Yes , I have to skip (0,0,0), that is a kind of requirement.

>
> Are you really getting floating point values, or are they always going
> to be equal to an integer?  Those if/elif statements might be a problem
> if you ever need to compare to a value like (128.4, 255.0, 255.0).
>

I dont have values with decimal part, All values are integer.

>
> --
>
> DaveA
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error .. Please Help

2012-12-12 Thread Ulrich Eckhardt

Am 12.12.2012 16:00, schrieb inshu chauhan:

 color = image[y,x]
 if color == (0.0,0.0,0.0):
 continue
 else :
 if color == (0.0,255.0,0.0):
 classification = 1
 elif color == (128.0, 0.0, 255.0):
 classification = 2
 elif color == (255.0,0.0,0.0):
 classification = 3
 elif color == (128.0, 128.0, 128.0):
 classification = 4
 elif color == (128.0, 64.0, 0.0):
 classification = 5
 elif color == (0.0, 0.0, 255.0):
 classification = 6
 elif color == (255.0, 0.0, 255.0):
 classification = 7



Use a dict for this, it probably makes things clearer. Something like:

  cclasses = {(  0.0,   0.0,   0.0): None,
  (  0.0, 255.0,   0.0): 1,
  (128.0,   0.0, 255.0): 2, }

  if cclasses[color] is not None:
  print >> g, x , y , color, cclasses[color]


Some notes:
 * Some people (and I think PEP8) frown upon the table formatting of 
the dict.
 * d[color] will raise an exception if there is no mapping, but it's 
not clear what you want to do with those inputs anyway.
 * Comparing floating-point values for equality is always a bit tricky, 
as most operations have some rounding. This could mean that you need to 
use ranges instead of fixed values. A good approach is to round the 
input to integral values first.
 * Are you sure that the input uses floating point values but uses 
typical 8-bit ranges 0-255? I would expect floating point values between 
0 and 1 or integral values between 0 and 255, but not such a mixture.
 * Try g.write('{} {} {} {}\n'.format(x, y, color, classification)) to 
get code that you will be able to reuse in Python 3. Also, consider 
upgrading anyway.




I am getting the following error..

Traceback (most recent call last):
   File "Z:\modules\Get_Classification.py", line 27, in 
 print >> g, x , y , color, classification
NameError: name 'classification' is not defined

Its simple error of name but m not getting why it should come as I have
already defined Classification in between if-else loop ??


One comment here: If you don't define "classification" in this loop 
iteration, the one from the previous iteration will be used. 
Effectively, this tells me that the first pixel unequal to (0,0,0) 
already doesn't fit your expectations. Use "import pdb" and 
"pdb.set_trace()" to get into debugging mode, which is a useful skill 
anyway.


Good luck!

Uli


--
http://mail.python.org/mailman/listinfo/python-list


Re: Error .. Please Help

2012-12-12 Thread Dave Angel
On 12/12/2012 10:00 AM, inshu chauhan wrote:
> In this code :
>
> import cv
> g = open("PointCloudmitClass.txt", "w")
> image = cv.LoadImageM("Z:/modules/intensity_01.tif",
> cv.CV_LOAD_IMAGE_UNCHANGED)
> print image
> for y in xrange(0,image.height):
> for x in xrange(0,image.width):
> color = image[y,x]
> if color == (0.0,0.0,0.0):
> continue
> else :
>
> if color == (0.0,255.0,0.0):
> classification = 1
> elif color == (128.0, 0.0, 255.0):
> classification = 2
> elif color == (255.0,0.0,0.0):
> classification = 3
> elif color == (128.0, 128.0, 128.0):
> classification = 4
> elif color == (128.0, 64.0, 0.0):
> classification = 5
> elif color == (0.0, 0.0, 255.0):
> classification = 6
> elif color == (255.0, 0.0, 255.0):
> classification = 7
>
> print >> g, x , y , color, classification
>
>
> I am getting the following error..
>
> Traceback (most recent call last):
>   File "Z:\modules\Get_Classification.py", line 27, in 
> print >> g, x , y , color, classification
> NameError: name 'classification' is not defined
>
> Its simple error of name but m not getting why it should come as I have
> already defined Classification in between if-else loop ??
>
if-else doesn't define a loop, but each of the for statements do.

You have defined a classification for 8 of the possible colors, leaving
millions of them undefined.  If the first time through the loop you
manage to hit one of those undefined ones, you'll have no value for
classification.  So you get an exception.

Worse, if you manage to get past that first pixel with a valid
classification, then for remaining pixels, you'll be using the last
'valid' classification encountered.  This is the kind of "quiet failure"
that programmers dread.  Something that seems to work, but isn't even close.

If you're going to print (to file) on each iteration through the loop
(except 0,0,0), you need to make sure there's always a valid value.  So
you need at least one more classification value, and an else clause to
assign it, as ChrisA pointed out.

Do you have a reason for treating (0,0,0) specially?  When that value is
seen, the logic skips the print as well, since continue skips to the
next loop iteration.

Are you really getting floating point values, or are they always going
to be equal to an integer?  Those if/elif statements might be a problem
if you ever need to compare to a value like (128.4, 255.0, 255.0).

-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error .. Please Help

2012-12-12 Thread Chris Angelico
On Thu, Dec 13, 2012 at 2:00 AM, inshu chauhan  wrote:
> In this code :
>
> import cv
> if color == (0.0,255.0,0.0):
> classification = 1
> ...
> elif color == (255.0, 0.0, 255.0):
> classification = 7
>
> print >> g, x , y , color, classification
>

What happens if the color isn't one of the ones you picked? You may
need an 'else' clause on your if/elif/elif block, and some
classification value meaning "other".

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Error .. Please Help

2012-12-12 Thread inshu chauhan
In this code :

import cv
g = open("PointCloudmitClass.txt", "w")
image = cv.LoadImageM("Z:/modules/intensity_01.tif",
cv.CV_LOAD_IMAGE_UNCHANGED)
print image
for y in xrange(0,image.height):
for x in xrange(0,image.width):
color = image[y,x]
if color == (0.0,0.0,0.0):
continue
else :

if color == (0.0,255.0,0.0):
classification = 1
elif color == (128.0, 0.0, 255.0):
classification = 2
elif color == (255.0,0.0,0.0):
classification = 3
elif color == (128.0, 128.0, 128.0):
classification = 4
elif color == (128.0, 64.0, 0.0):
classification = 5
elif color == (0.0, 0.0, 255.0):
classification = 6
elif color == (255.0, 0.0, 255.0):
classification = 7

print >> g, x , y , color, classification


I am getting the following error..

Traceback (most recent call last):
  File "Z:\modules\Get_Classification.py", line 27, in 
print >> g, x , y , color, classification
NameError: name 'classification' is not defined

Its simple error of name but m not getting why it should come as I have
already defined Classification in between if-else loop ??

Thanks in Advance !!!


IC
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import gzip error (please help)

2008-01-13 Thread syahreza.octadian
On Jan 11, 7:14 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> the core zlib library (libz.so) isn't installed on your machine.


but in my machine there is file
-rwxr-xr-x   1 bin  bin48576 Sep 20  2006 /usr/local/lib/
python2.5/lib-dynload/zlib.so


if i have to install zlib library core, where i can found it for
solaris 10 sparcv.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import gzip error (please help)

2008-01-11 Thread Fredrik Lundh
syahreza.octadian wrote:

> Please help, i have error message when i import gzip module. The error
> like this below:
> 
> bash-3.00$ python
> Python 2.5 (r25:51908, Sep 20 2006, 03:46:40)
> [GCC 3.4.6] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.
 import gzip
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/local/lib/python2.5/gzip.py", line 9, in 
> import zlib
> ImportError: ld.so.1: python: fatal: relocation error: file /usr/local/
> lib/python2.5/lib-dynload/zlib.so: symbol inflateCopy: referenced
> symbol not found

the core zlib library (libz.so) isn't installed on your machine.



-- 
http://mail.python.org/mailman/listinfo/python-list


import gzip error (please help)

2008-01-11 Thread syahreza.octadian
Dear all,

Please help, i have error message when i import gzip module. The error
like this below:

bash-3.00$ python
Python 2.5 (r25:51908, Sep 20 2006, 03:46:40)
[GCC 3.4.6] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.5/gzip.py", line 9, in 
import zlib
ImportError: ld.so.1: python: fatal: relocation error: file /usr/local/
lib/python2.5/lib-dynload/zlib.so: symbol inflateCopy: referenced
symbol not found


Thx u.
Syahreza Octadian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python readline error - please help - need it for scanner!

2006-09-08 Thread Frederic Wenzel
On 9/8/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> can configure, make and install
> everything fine.  I'm using python 2.4  I have ubuntu dapper drake. I am
> trying to install hplip which requires python.  When I do this, this
> also works but while running the following error occurs:
> Traceback (most recent call last):
>   File "/usr/local/bin/hp-setup", line 31, in ?
> import readline, gzip
> ImportError: No module named readline
>
>
> It appears as though for some reaosn the readline module is not being
> installed on my system.

I suggest you uninstall python from your system:

sudo apt-get remove python

and reinstall it. Maybe something went wrong the first time you tried
(reboot while installing or other crazy things).

The python packages coming with Ubuntu are working pretty well, usually.

Fred
-- 
http://mail.python.org/mailman/listinfo/python-list


python readline error - please help - need it for scanner!

2006-09-08 Thread benjamin . grant
can configure, make and install
everything fine.  I'm using python 2.4  I have ubuntu dapper drake. I am
trying to install hplip which requires python.  When I do this, this
also works but while running the following error occurs:
Traceback (most recent call last):
  File "/usr/local/bin/hp-setup", line 31, in ?
import readline, gzip
ImportError: No module named readline



It appears as though for some reaosn the readline module is not being
installed on my system.  Also, it doesn't really seem like python could
possibly be being installed correctly.  If I go to python tools and try
to run ./listmodules I get the following error:


[Hide Quoted Text]
> File "/usr/lib/python2.4/doc/tools/listmodules", line 183, in ?
> main()
>   File "/usr/lib/python2.4/doc/tools/listmodules", line 119, in main
> os.chdir("Modules")
> OSError: [Errno 2] No such file or directory: 'Modules'
>
>

-- 
http://mail.python.org/mailman/listinfo/python-list