Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-25 Thread Weatherby,Gerard
“So the case where the assumption fails may not be easily
reproducable and the more information you can get post-mortem the
better”

That’s true for rare corner cases or esoteric race conditions. Usually, when I 
see asserts it's just because I was just plain stupid.

From: Python-list  on 
behalf of Peter J. Holzer 
Date: Saturday, February 25, 2023 at 5:21 PM
To: python-list@python.org 
Subject: Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) 
values are ?
On 2023-02-25 21:58:18 +, Weatherby,Gerard wrote:
> I only use asserts for things I know to be true.

Yeah, that's what assers are for. Or rather for things that you *think*
are true.

> In other words, a failing assert means I have a hole in my program
> logic.

Yes, if you include your assumptions in your definition of "logic".


> For that use, the default behavior –telling me which line the assert
> is on, is more than sufficient. Depending on the circumstance, I’ll
> re-run the code with a breakpoint or replace the assert with an
> informative f-string Exception.

That may not always be practical. Things that we know (or think) are
true often have *are* true in most cases (otherwise we wouldn't think
so). So the case where the assumption fails may not be easily
reproducable and the more information you can get post-mortem the
better. For example, in C on Linux a failed assertion causes a core
dump. So you can inspect the complete state of the program.

hp

--
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-25 Thread Peter J. Holzer
On 2023-02-25 21:58:18 +, Weatherby,Gerard wrote:
> I only use asserts for things I know to be true.

Yeah, that's what assers are for. Or rather for things that you *think*
are true.

> In other words, a failing assert means I have a hole in my program
> logic.

Yes, if you include your assumptions in your definition of "logic".


> For that use, the default behavior –telling me which line the assert
> is on, is more than sufficient. Depending on the circumstance, I’ll
> re-run the code with a breakpoint or replace the assert with an
> informative f-string Exception.

That may not always be practical. Things that we know (or think) are
true often have *are* true in most cases (otherwise we wouldn't think
so). So the case where the assumption fails may not be easily
reproducable and the more information you can get post-mortem the
better. For example, in C on Linux a failed assertion causes a core
dump. So you can inspect the complete state of the program.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-25 Thread Weatherby,Gerard
I only use asserts for things I know to be true. Nothing is harder to debug 
than when something you know to be true turns out to be… not True. Because I’ll 
check everything else instead of the cause of the bug.

In other words, a failing assert means I have a hole in my program logic.

For that use, the default behavior –telling me which line the assert is on, is 
more than sufficient. Depending on the circumstance, I’ll re-run the code with 
a breakpoint or replace the assert with an informative f-string Exception.



From: Python-list  on 
behalf of Peter J. Holzer 
Date: Saturday, February 25, 2023 at 9:22 AM
To: python-list@python.org 
Subject: Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) 
values are ?
On 2023-02-25 09:10:06 -0500, Thomas Passin wrote:
> On 2/25/2023 1:13 AM, Peter J. Holzer wrote:
> > On 2023-02-24 18:19:52 -0500, Thomas Passin wrote:
> > > Sometimes you can use a second parameter to assert if you know what kind 
> > > of
> > > error to expect:
[...]
> > > With type errors, assert may actually give you the information needed:
> > >
> > > > > > c = {"a": a, "b": 2}
> > > > > > assert a > c
> > > Traceback (most recent call last):
> > >File "", line 1, in 
> > > TypeError: '>' not supported between instances of 'list' and 'dict'
> >
> > Actually in this case it isn't assert which gives you the information,
> > it's evaluating the expression itself. You get the same error with just
> >  a > c
> > on a line by its own.
>
> In some cases.  For my example with an explanatory string, you wouldn't want
> to write code like that after an ordinary line of code, at least not very
> often.  The assert statement allows it syntactically.

Yes, but if an error in the expression triggers an exception (as in this
case) the explanatory string will never be displayed.

hp

--
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-25 Thread Peter J. Holzer
On 2023-02-25 09:10:06 -0500, Thomas Passin wrote:
> On 2/25/2023 1:13 AM, Peter J. Holzer wrote:
> > On 2023-02-24 18:19:52 -0500, Thomas Passin wrote:
> > > Sometimes you can use a second parameter to assert if you know what kind 
> > > of
> > > error to expect:
[...]
> > > With type errors, assert may actually give you the information needed:
> > > 
> > > > > > c = {"a": a, "b": 2}
> > > > > > assert a > c
> > > Traceback (most recent call last):
> > >File "", line 1, in 
> > > TypeError: '>' not supported between instances of 'list' and 'dict'
> > 
> > Actually in this case it isn't assert which gives you the information,
> > it's evaluating the expression itself. You get the same error with just
> >  a > c
> > on a line by its own.
> 
> In some cases.  For my example with an explanatory string, you wouldn't want
> to write code like that after an ordinary line of code, at least not very
> often.  The assert statement allows it syntactically.

Yes, but if an error in the expression triggers an exception (as in this
case) the explanatory string will never be displayed.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-25 Thread Thomas Passin

On 2/25/2023 1:13 AM, Peter J. Holzer wrote:

On 2023-02-24 18:19:52 -0500, Thomas Passin wrote:

On 2/24/2023 2:47 PM, dn via Python-list wrote:

On 25/02/2023 08.12, Peter J. Holzer wrote:

On 2023-02-24 16:12:10 +1300, dn via Python-list wrote:

In some ways, providing this information seems appropriate.
Curiously, this does not even occur during an assert exception -
despite the value/relationship being the whole point of using
the command!

  x = 1
  assert x == 2

AssertionError (and that's it)


Sometimes you can use a second parameter to assert if you know what kind of
error to expect:


a = [1,2,3]
b = [4,5]
assert len(a) == len(b), f'len(a): {len(a)} != len(b): {len(b)}'

Traceback (most recent call last):
   File "", line 1, in 
AssertionError: len(a): 3 != len(b): 2


Yup. That's very useful (but I tend to forget that).



With type errors, assert may actually give you the information needed:


c = {"a": a, "b": 2}
assert a > c

Traceback (most recent call last):
   File "", line 1, in 
TypeError: '>' not supported between instances of 'list' and 'dict'


Actually in this case it isn't assert which gives you the information,
it's evaluating the expression itself. You get the same error with just
 a > c
on a line by its own.


In some cases.  For my example with an explanatory string, you wouldn't 
want to write code like that after an ordinary line of code, at least 
not very often.  The assert statement allows it syntactically.


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


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
On 2023-02-24 18:19:52 -0500, Thomas Passin wrote:
> On 2/24/2023 2:47 PM, dn via Python-list wrote:
> > On 25/02/2023 08.12, Peter J. Holzer wrote:
> > > On 2023-02-24 16:12:10 +1300, dn via Python-list wrote:
> > > > In some ways, providing this information seems appropriate.
> > > > Curiously, this does not even occur during an assert exception -
> > > > despite the value/relationship being the whole point of using
> > > > the command!
> > > > 
> > > >  x = 1
> > > >  assert x == 2
> > > > 
> > > > AssertionError (and that's it)
> 
> Sometimes you can use a second parameter to assert if you know what kind of
> error to expect:
> 
> >>> a = [1,2,3]
> >>> b = [4,5]
> >>> assert len(a) == len(b), f'len(a): {len(a)} != len(b): {len(b)}'
> Traceback (most recent call last):
>   File "", line 1, in 
> AssertionError: len(a): 3 != len(b): 2

Yup. That's very useful (but I tend to forget that).


> With type errors, assert may actually give you the information needed:
> 
> >>> c = {"a": a, "b": 2}
> >>> assert a > c
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: '>' not supported between instances of 'list' and 'dict'

Actually in this case it isn't assert which gives you the information,
it's evaluating the expression itself. You get the same error with just
a > c
on a line by its own.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Thomas Passin

On 2/24/2023 2:47 PM, dn via Python-list wrote:

On 25/02/2023 08.12, Peter J. Holzer wrote:

On 2023-02-24 16:12:10 +1300, dn via Python-list wrote:
In some ways, providing this information seems appropriate. 
Curiously, this

does not even occur during an assert exception - despite the
value/relationship being the whole point of using the command!

 x = 1
 assert x == 2

AssertionError (and that's it)


Sometimes you can use a second parameter to assert if you know what kind 
of error to expect:


>>> a = [1,2,3]
>>> b = [4,5]
>>> assert len(a) == len(b), f'len(a): {len(a)} != len(b): {len(b)}'
Traceback (most recent call last):
  File "", line 1, in 
AssertionError: len(a): 3 != len(b): 2

With type errors, assert may actually give you the information needed:

>>> c = {"a": a, "b": 2}
>>> assert a > c
Traceback (most recent call last):
  File "", line 1, in 
TypeError: '>' not supported between instances of 'list' and 'dict'

So now we know that a is a list and c is a dictionary.


Pytest is great there. If an assertion in a test case fails it analyzes
the expression to give you various levels of details:

 test session starts 


platform linux -- Python 3.10.6, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /home/hjp/tmp/t
plugins: cov-3.0.0, anyio-3.6.1
collected 1 item

test_a.py 
F   [100%]


= FAILURES 
==
__ test_a 
___


 def test_a():
 a = [1, 2, 3]
 b = {"a": a, "b": 2}


   assert len(a) == len(b)

E   AssertionError: assert 3 == 2
E    +  where 3 = len([1, 2, 3])
E    +  and   2 = len({'a': [1, 2, 3], 'b': 2})

test_a.py:7: AssertionError
== short test summary info 
==

FAILED test_a.py::test_a - AssertionError: assert 3 == 2
= 1 failed in 0.09s 
=


+1
and hence the tone of slight surprise in the observation - because only 
ever use assert within pytests, and as observed, pytest amplifies the 
report-back to provide actionable-intelligence. See also: earlier 
contribution about using a debugger.



That said, have observed coders 'graduating' from other languages, 
making wider use of assert - assumed to be more data (value) 
sanity-checks than typing, but ...


Do you use assert frequently?


The OP seems wedded to his?her ways, complaining that Python does not 
work the way it 'should'. In turn, gives rise to the impression that 
expounding the advantages of TDD, and thus anticipating such unit and 
integration error-possibilities, might be considered an insult or 
unhelpful.

(sigh!)

Personally, I struggled a bit to adapt from the more-strictured (if not 
more-structured) languages of my past, to Python - particularly the 
different philosophies or emphases of what happens at 'compile-time' cf 
'execution-time'; and how such required marked changes in attitudes to 
design, time-allocation, work-flow, and tool-set. Two related-activities 
which made the language-change more workable and unleashed greater than 
step-change advantage, were: increased use of TDD, and actively learning 
the facilities within Python-oriented IDEs.




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


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
On 2023-02-25 08:47:00 +1300, dn via Python-list wrote:
> That said, have observed coders 'graduating' from other languages, making
> wider use of assert - assumed to be more data (value) sanity-checks than
> typing, but ...
> 
> Do you use assert frequently?

Not very often, but I do use it. Sometimes for its intended purpose
(i.e. to guard against bugs or wrong assumptions), sometimes just to
guard incomplete or sloppy code (e.g. browsing through some projects I
find
assert len(data["structure"]["dimensions"]["observation"]) == 1
(incomplete code - I didn't bother to implement multiple observations)
and
assert(header[0] == "Monat (MM)")
(the code below is sloppy. Instead of fixing it I just made the original
programmer's assumptions explicit)
and of course
assert False
(this point should never be reached)).

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread dn via Python-list

On 25/02/2023 08.12, Peter J. Holzer wrote:

On 2023-02-24 16:12:10 +1300, dn via Python-list wrote:

In some ways, providing this information seems appropriate. Curiously, this
does not even occur during an assert exception - despite the
value/relationship being the whole point of using the command!

 x = 1
 assert x == 2

AssertionError (and that's it)


Pytest is great there. If an assertion in a test case fails it analyzes
the expression to give you various levels of details:

 test session starts 

platform linux -- Python 3.10.6, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /home/hjp/tmp/t
plugins: cov-3.0.0, anyio-3.6.1
collected 1 item

test_a.py F 
  [100%]

= FAILURES 
==
__ test_a 
___

 def test_a():
 a = [1, 2, 3]
 b = {"a": a, "b": 2}


   assert len(a) == len(b)

E   AssertionError: assert 3 == 2
E+  where 3 = len([1, 2, 3])
E+  and   2 = len({'a': [1, 2, 3], 'b': 2})

test_a.py:7: AssertionError
== short test summary info 
==
FAILED test_a.py::test_a - AssertionError: assert 3 == 2
= 1 failed in 0.09s 
=


+1
and hence the tone of slight surprise in the observation - because only 
ever use assert within pytests, and as observed, pytest amplifies the 
report-back to provide actionable-intelligence. See also: earlier 
contribution about using a debugger.



That said, have observed coders 'graduating' from other languages, 
making wider use of assert - assumed to be more data (value) 
sanity-checks than typing, but ...


Do you use assert frequently?


The OP seems wedded to his?her ways, complaining that Python does not 
work the way it 'should'. In turn, gives rise to the impression that 
expounding the advantages of TDD, and thus anticipating such unit and 
integration error-possibilities, might be considered an insult or unhelpful.

(sigh!)

Personally, I struggled a bit to adapt from the more-strictured (if not 
more-structured) languages of my past, to Python - particularly the 
different philosophies or emphases of what happens at 'compile-time' cf 
'execution-time'; and how such required marked changes in attitudes to 
design, time-allocation, work-flow, and tool-set. Two related-activities 
which made the language-change more workable and unleashed greater than 
step-change advantage, were: increased use of TDD, and actively learning 
the facilities within Python-oriented IDEs.


--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
On 2023-02-24 16:12:10 +1300, dn via Python-list wrote:
> In some ways, providing this information seems appropriate. Curiously, this
> does not even occur during an assert exception - despite the
> value/relationship being the whole point of using the command!
> 
> x = 1
> assert x == 2
> 
> AssertionError (and that's it)

Pytest is great there. If an assertion in a test case fails it analyzes
the expression to give you various levels of details:

 test session starts 

platform linux -- Python 3.10.6, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /home/hjp/tmp/t
plugins: cov-3.0.0, anyio-3.6.1
collected 1 item

test_a.py F 
  [100%]

= FAILURES 
==
__ test_a 
___

def test_a():
a = [1, 2, 3]
b = {"a": a, "b": 2}

>   assert len(a) == len(b)
E   AssertionError: assert 3 == 2
E+  where 3 = len([1, 2, 3])
E+  and   2 = len({'a': [1, 2, 3], 'b': 2})

test_a.py:7: AssertionError
== short test summary info 
==
FAILED test_a.py::test_a - AssertionError: assert 3 == 2
= 1 failed in 0.09s 
=

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
On 2023-02-23 20:32:26 -0700, Michael Torrie wrote:
> On 2/23/23 01:08, Hen Hanna wrote:
> >  Python VM  is seeing an "int" object (123)   (and telling me that)
> >  ...   so it should be easy to print that "int" object What does
> >  Python VMknow ?   and when does it know it ?
> It knows there is an object and its name and type.  It knows this from
> the first moment you create the object and bind a name to it.
> > it seems like  it is being playful, teasing (or mean),and
> > hiding  the ball from me
> 
> Sorry you aren't understanding.  Whenever you print() out an object,
> python calls the object's __repr__() method to generate the string to
> display.  For built-in objects this is obviously trivial. But if you
> were dealing an object of some arbitrary class, there may not be a
> __repr__() method

Is this even possible? object has a __repr__ method, so all other
classes would inherit that if they don't define one themselves. I guess
it's possible to explicitely remove it ...

> which would cause an exception, or if the __repr__()
> method itself raised an exception,

Yup. That is possible and has happened to me several times - of course
always in a situation where I really needed that output ...

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-24 Thread Peter J. Holzer
On 2023-02-22 15:46:09 -0800, Hen Hanna wrote:
> On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote:
> > > py bug.py 
> > Traceback (most recent call last): 
> > File "C:\Usenet\bug.py", line 5, in  
> > print( a + 12 ) 
> > TypeError: can only concatenate str (not "int") to str 
> > 
> > 
> > Why doesn't Python (error msg) do the obvious thing and tell me 
> > WHAT the actual (offending, arg) values are ? 
> > 
> > In many cases, it'd help to know what string the var A had , when the error 
> > occurred. 
> >  i wouldn't have to put print(a) just above, to see. 
> > 
> > ( pypy doesn't do that either, but Python makes programming
> > (debugging) so easy that i hardly feel any inconvenience.)

That seems like a non-sequitur to me. If you hardly feel any
inconvenience, why argue so forcefully?
And why is pypy relevant here?


> i  see that my example   would be clearER  with this one-line  change:
> 
> 
>   >  py   bug.py
> 
>Traceback (most recent call last):
> 
>   File "C:\Usenet\bug.py", line 5, in 
>  map( Func,fooBar(  X,  Y,  X +  
> Y  ))
>  
>TypeError: can only concatenate str (not "int") to str
> 
> 
> i hope that   NOW   a few of you  can  see this as a genuine,  (reasonable)  
> question.

That doesn't seem a better example to me. There is still only one
subexpression (X + Y) where that error can come from, so I know that X
is a str and Y is an int.

A better example would be something like 

x = (a + b) * (c + d)

In this case it could be either (a + b) or (c + d) which caused the
error. But what I really want to know here is the names of the involved
variables, NOT the values. If the error message told me that the values
were 'foo' and 12.3, I still wouldn't be any wiser. The problem here of
course is that the operands aren't necessarily simple variables as in
this example - they may be arbitrarily complex expressions. However, it
might be sufficient to mark the operator which caused the exception:

|   ...
|   File "/home/hjp/tmp/./foo", line 4, in f
| return (a + b) * (c + d)
| ^
| TypeError: can only concatenate str (not "int") to str

would tell me that (c + d) caused the problem and therefore that c must
be a str which it obviously shouldn't be.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread avi.e.gross
We have been supplying many possible reasons or consequences for why the
implementation of python does not do what the OP wants and even DEMANDS.

I am satisfied with knowing it was because they CHOSE NOT TO in some places
and maybe not in others. It is nice to see some possible reasons, but
something as simple as efficiency or needing to complicate the code in
something used regularly, might be enough for now.

But to comment on what Michael T. and Dave N. have been saying, newcomers
often have no clue of what can happen so their questions may sound quite
reasonable.

So what happens if you create a large data structure, so some operation that
fails, catch the error and save the variables involved in an exception and
throw that onward and perhaps the program keeps running? There is now a
pointer to the large data structure in the exception object, or even a copy.
If that exception is not discarded or garbage collected, it can remain in
memory indefinitely even if the original string was expected to be removed,
replaced, or garbage collected. Some modern features in R such as generators
will stay alive infinitely and retain their state in between calls for a
next item.

You can end up with memory leaks that are not trivial to solve or that may
mysteriously disappear when an iterable has finally been consumed and all
the storage it used or pointed at can be retrieved, as one example.

A more rational approach is to realize that python has multiple levels of
debugging and exceptions are one among many. They are not meant to solve the
entire problem but just enough to be helpful or point you in some direction.
Yes, they can do more.

And, FYI, I too pointed this person at the Tutor list and I see no sign they
care how many people they make waste their time with so many mainly gripes.
I personally now ignore any post by them.
-Original Message-
From: Python-list  On
Behalf Of Michael Torrie
Sent: Thursday, February 23, 2023 10:32 PM
To: python-list@python.org
Subject: Re: Why doesn't Python (error msg) tell me WHAT the actual (arg)
values are ?

On 2/23/23 01:08, Hen Hanna wrote:
>  Python VM  is seeing an "int" object (123)   (and telling me that)   ...
so it should be easy to print that "int" object 
> What does  Python VMknow ?   and when does it know it ?
It knows there is an object and its name and type.  It knows this from the
first moment you create the object and bind a name to it.
> it seems like  it is being playful, teasing (or mean),and   hiding
the ball from me

Sorry you aren't understanding.  Whenever you print() out an object, python
calls the object's __repr__() method to generate the string to display.  For
built-in objects this is obviously trivial. But if you were dealing an
object of some arbitrary class, there may not be a
__repr__() method which would cause an exception, or if the __repr__()
method itself raised an exception, you'd lose the original error message and
the stack trace would be all messed up and of no value to you.  Does that
make sense?  Remember that Python is a very dynamic language and what might
be common sense for a built-in type makes no sense at all for a custom type.
Thus there's no consistent way for Python to print out the information you
think is so simple.
--
https://mail.python.org/mailman/listinfo/python-list

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


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Michael Torrie
On 2/23/23 01:08, Hen Hanna wrote:
>  Python VM  is seeing an "int" object (123)   (and telling me that)   ...   
> so it should be easy to print that "int" object 
> What does  Python VMknow ?   and when does it know it ?
It knows there is an object and its name and type.  It knows this from
the first moment you create the object and bind a name to it.
> it seems like  it is being playful, teasing (or mean),and   hiding  the 
> ball from me

Sorry you aren't understanding.  Whenever you print() out an object,
python calls the object's __repr__() method to generate the string to
display.  For built-in objects this is obviously trivial. But if you
were dealing an object of some arbitrary class, there may not be a
__repr__() method which would cause an exception, or if the __repr__()
method itself raised an exception, you'd lose the original error message
and the stack trace would be all messed up and of no value to you.  Does
that make sense?  Remember that Python is a very dynamic language and
what might be common sense for a built-in type makes no sense at all for
a custom type.  Thus there's no consistent way for Python to print out
the information you think is so simple.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread dn via Python-list

On 23/02/2023 09.05, Hen Hanna wrote:


   >  py   bug.py
Traceback (most recent call last):
  File "C:\Usenet\bug.py", line 5, in 
  print( a + 12 )
   TypeError: can only concatenate str (not "int") to str


Why doesn't  Python (error msg) do the obvious thing and tell me
 WHAT   the actual   (offending,  arg)  values are ?

In many cases, it'd help to know what string the var  A  had  ,   when the 
error occurred.
    i wouldn't have to put  print(a) just 
above,  to see.


In some ways, providing this information seems appropriate. Curiously, 
this does not even occur during an assert exception - despite the 
value/relationship being the whole point of using the command!


x = 1
assert x == 2

AssertionError (and that's it)

Then again, remember that exceptions can be 'caught'. So, such data 
would need to be added to the exception-instance. This could become 
quite costly.




What are the appropriate tools for the job?


Don't add an extra print(), use a debugger.

Not only does this allow you to breakpoint critical points in the code, 
but identifiers can be watch-ed and changes noted. The other handy 
feature is being able to correct the current erroneous value of the 
identifier and continue execution.


For us, memory-challenged coders, there is no need to remember to remove 
the print() again, afterwards.



The TypeError indicates a problem between the programmer's ears. What 
was thought to be a string or an integer was the opposite. This seems to 
be playing fast-and-loose with Python's dynamic-typing. To quote: "we're 
all adults here". Thus, I wouldn't recommend 're-cycling' an identifier 
to represent two different (types of) data-point in the same code - but 
there's nothing to stop you/anyone!


The other possibility is that it was an accident. Sounds more like 
something I would do, but... In this case, the tool which is your/my 
friend is typing. The IDE should catch most of the situations where an 
int would be used as an str, or v-v. Remember though, Python's typing is 
(a) not part of the language, and (b) probably won't help at run-time.



PS are you aware that there is a Python-Tutor list for the use of people 
learning Python?

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


RE: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread avi.e.gross
l error but a
temporary drawback. Only when int fails too is there a likely error but int
is not programmed to do anything lie reporting in __iadd__() and nor should
it except if you are debugging new functionality.

Can we get better error messages in many cases? Sure. Clearly the
interpreter level sees a call like func(x, y, x+y) and if evaluating it
causes an error, it could type out what all the variables were. 

But if you are running code at the console and it aborts like this, you
usually have the variables at your fingertips and can say print(x) or
print(y) but you cannot properly say print(x+y) yet. The error message did
specify you were trying to work with incompatible objects as one was of type
this and the other of type that. That suggests the values of both could have
been accessed and shown in this case ad perhaps the code could be modified
so it returns some semblance of the values at least for built-in objects.
All that though adds code and complexity and often slows things down. 



-Original Message-
From: Python-list  On
Behalf Of Rob Cliffe via Python-list
Sent: Wednesday, February 22, 2023 4:31 PM
To: python-list@python.org
Subject: Re: Why doesn't Python (error msg) tell me WHAT the actual (arg)
values are ?



On 22/02/2023 20:05, Hen Hanna wrote:
> Python makes programming (debugging) so easy
I agree with that!
Rob Cliffe
-- 
https://mail.python.org/mailman/listinfo/python-list

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


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Rob Cliffe via Python-list




On 22/02/2023 20:05, Hen Hanna wrote:

Python makes programming (debugging) so easy

I agree with that!
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Hen Hanna
On Wednesday, February 22, 2023 at 11:57:45 PM UTC-8, Barry wrote:
> > On 23 Feb 2023, at 01:39, Hen Hanna  wrote:
> > 
> > On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, Hen Hanna wrote: 
> >> On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: 
> >>>> py bug.py 
> >>> Traceback (most recent call last): 
> >>> File "C:\Usenet\bug.py", line 5, in  
> >>> print( a + 12 ) 
> >>> TypeError: can only concatenate str (not "int") to str 
> >>> 
> >>> 
> >>> Why doesn't Python (error msg) do the obvious thing and tell me 
> >>> WHAT the actual (offending, arg) values are ? 
> >>> 
> >>> In many cases, it'd help to know what string the var A had , when the 
> >>> error occurred. 
> >>>  i wouldn't have to put print(a) just above, to see. 
> >>> 
> >>> 
> >>> 
> >>> 
> >>> ( pypy doesn't do that either, but Python makes programming (debugging) 
> >>> so easy that i hardly feel any inconvenience.) 
> > 
> > 
> > i see that my example would be (even) clearER with this one-line change: 
> > 
> > py bug.py 
> > 
> > Traceback (most recent call last): 
> > 
> > File "C:\Usenet\bug.py", line 5, in  
> > map( Func, fooBar( X, Y, X + Y )) 
> > 
> > TypeError: can only concatenate str (not "int") to str 
> >   attempt to call +  with   'abc',  123 
> >   <-- 
> > 
> >> i hope that NOW a few of you can see this as a genuine, (reasonable) 
> >> question. 
> > 
> > Python seems so perfectly User-friendly that 
> > i 'm so curious (puzzled) that it doesn't do the very obvious and easy 
> > thing 
> > of giving me this info: 
> > 
> > attempt to call +with   'abc',   
> > 123 <--

> It is not easy to do that in a robust and reliable way for any object. 
> You can end up in the code to generate the error message itself breaking. 
> For example using unbounded CPU time when attempting to get the string repr 
> of the variable. 
> 
> Barry 
> 


 Python VM  is seeing an "int" object (123)   (and telling me that)   ...   so 
it should be easy to print that "int" object 


What does  Python VMknow ?   and when does it know it ?


it seems like  it is being playful, teasing (or mean),and   hiding  the 
ball from me
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Barry


> On 23 Feb 2023, at 01:39, Hen Hanna  wrote:
> 
> On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, Hen Hanna wrote:
>> On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: 
>>>> py bug.py 
>>> Traceback (most recent call last): 
>>> File "C:\Usenet\bug.py", line 5, in  
>>> print( a + 12 ) 
>>> TypeError: can only concatenate str (not "int") to str 
>>> 
>>> 
>>> Why doesn't Python (error msg) do the obvious thing and tell me 
>>> WHAT the actual (offending, arg) values are ? 
>>> 
>>> In many cases, it'd help to know what string the var A had , when the error 
>>> occurred. 
>>>  i wouldn't have to put print(a) just above, to see. 
>>> 
>>> 
>>> 
>>> 
>>> ( pypy doesn't do that either, but Python makes programming (debugging) so 
>>> easy that i hardly feel any inconvenience.)
> 
> 
> i see that my example would be (even)  clearER with this one-line change:
> 
>   py bug.py 
> 
> Traceback (most recent call last): 
> 
>   File "C:\Usenet\bug.py", line 5, in 
> map( Func, fooBar( X, Y, X + Y ))
> 
> TypeError: can only concatenate str (not "int") to str
>attempt to call +  with  'abc'  ,   123.45  
> <--
> 
>> i hope that NOW a few of you can see this as a genuine, (reasonable) 
>> question.
> 
> Python  seems so perfectly  User-friendly that
>   i 'm  so curious (puzzled)  that it doesn't do the very  
> obvious and easy thing 
> of giving me this info:
> 
>attempt to call  + with  'abc'  ,   
> 123.45  <--

It is not easy to do that in a robust and reliable way for any object.
You can end up in the code to generate the error message itself breaking.
For example using unbounded CPU time when attempting to get the string repr of 
the variable.

Barry

> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 3:46:21 PM UTC-8, Hen Hanna wrote:
> On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote: 
> > > py bug.py 
> > Traceback (most recent call last): 
> > File "C:\Usenet\bug.py", line 5, in  
> > print( a + 12 ) 
> > TypeError: can only concatenate str (not "int") to str 
> > 
> > 
> > Why doesn't Python (error msg) do the obvious thing and tell me 
> > WHAT the actual (offending, arg) values are ? 
> > 
> > In many cases, it'd help to know what string the var A had , when the error 
> > occurred. 
> >  i wouldn't have to put print(a) just above, to see. 
> > 
> > 
> > 
> > 
> > ( pypy doesn't do that either, but Python makes programming (debugging) so 
> > easy that i hardly feel any inconvenience.)


 i see that my example would be (even)  clearER with this one-line change:

   py bug.py 
   
 Traceback (most recent call last): 
  
   File "C:\Usenet\bug.py", line 5, in 
 map( Func, fooBar( X, Y, X + Y ))

 TypeError: can only concatenate str (not "int") to str
attempt to call +  with  'abc'  ,   123.45  
<--

> i hope that NOW a few of you can see this as a genuine, (reasonable) question.

Python  seems so perfectly  User-friendly that
   i 'm  so curious (puzzled)  that it doesn't do the very  
obvious and easy thing 
 of giving me this info:

attempt to call  + with  'abc'  ,   
123.45  <--
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Thomas Passin

On 2/22/2023 6:46 PM, Hen Hanna wrote:

On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote:

py bug.py

Traceback (most recent call last):
File "C:\Usenet\bug.py", line 5, in 
print( a + 12 )
TypeError: can only concatenate str (not "int") to str


Why doesn't Python (error msg) do the obvious thing and tell me
WHAT the actual (offending, arg) values are ?

In many cases, it'd help to know what string the var A had , when the error 
occurred.
 i wouldn't have to put print(a) just above, to see.




( pypy doesn't do that either, but Python makes programming (debugging) so easy 
that i hardly feel any inconvenience.)




i  see that my example   would be clearER  with this one-line  change:


   >  py   bug.py

Traceback (most recent call last):

   File "C:\Usenet\bug.py", line 5, in 
  map( Func,fooBar(  X,  Y,  X +  Y 
 ))
  
TypeError: can only concatenate str (not "int") to str



i hope that   NOW   a few of you  can  see this as a genuine,  (reasonable)  
question.


It tells me to go look at the function definition and how it's being 
invoked.  Even if I knew which of (X, Y) was an int and which a str, I'd 
still need to do that.


Or you could add type annotations to your code and run mypy on it...


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


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna
On Wednesday, February 22, 2023 at 12:05:34 PM UTC-8, Hen Hanna wrote:
> > py bug.py 
> Traceback (most recent call last): 
> File "C:\Usenet\bug.py", line 5, in  
> print( a + 12 ) 
> TypeError: can only concatenate str (not "int") to str 
> 
> 
> Why doesn't Python (error msg) do the obvious thing and tell me 
> WHAT the actual (offending, arg) values are ? 
> 
> In many cases, it'd help to know what string the var A had , when the error 
> occurred. 
>  i wouldn't have to put print(a) just above, to see. 
> 
> 
> 
> 
> ( pypy doesn't do that either, but Python makes programming (debugging) so 
> easy that i hardly feel any inconvenience.)



i  see that my example   would be clearER  with this one-line  change:


  >  py   bug.py

   Traceback (most recent call last):

  File "C:\Usenet\bug.py", line 5, in 
 map( Func,fooBar(  X,  Y,  X +  Y  
))
 
   TypeError: can only concatenate str (not "int") to str


i hope that   NOW   a few of you  can  see this as a genuine,  (reasonable)  
question.

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


RE: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread avi.e.gross
Hen or Hanna,

You keep asking WHY which may be reasonable but hard or irrelevant in many
cases.

I find the traceback perfectly informative.

It says you asked it to print NOT just "a" but "a + 12" and the error is
coming not from PRINT but from trying to invoke addition between two objects
that have not provided instructions on how to do so. Specifically, an object
of type str has not specified anything to do if asked to concatenate an
object of type int to it. And, an object of type int has not specified what
to do if asked to add itself to an object of type str to the left of it.
Deeper in python, the objects have dunder methods like __ADD__() and
___RADD__() to invoke for those situations that do some logic and decide
they cannot handle it and return an exception of sorts that ends up
generating your message.

If you want to know what "a" has at the moment, ask for just it, not adding
twelve to it. Perhaps you should add a line above your print asking to just
print(a).

Before you suggest what might be helpful, consider what it might mean in a
complex case with lots of variables and what work the interpreter might have
to do to dump the current values of anything relevant or just ANYTHING.

The way forward is less about asking why but asking what to do to get what
you want, or realize it is not attained the way you thought.

Avi

-Original Message-
From: Python-list  On
Behalf Of Hen Hanna
Sent: Wednesday, February 22, 2023 3:05 PM
To: python-list@python.org
Subject: Why doesn't Python (error msg) tell me WHAT the actual (arg) values
are ?


  >  py   bug.py
   Traceback (most recent call last):
 File "C:\Usenet\bug.py", line 5, in 
 print( a + 12 )
  TypeError: can only concatenate str (not "int") to str


Why doesn't  Python (error msg) do the obvious thing and tell me
WHAT   the actual   (offending,  arg)  values are ?

In many cases, it'd help to know what string the var  A  had  ,   when the
error occurred.
   i wouldn't have to put  print(a) just
above,  to see.




( pypydoesn't do that either,   but Python makes programming (debugging)
so easy that i hardly feel any inconvenience.)
-- 
https://mail.python.org/mailman/listinfo/python-list

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


Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-22 Thread Hen Hanna


  >  py   bug.py
   Traceback (most recent call last):
 File "C:\Usenet\bug.py", line 5, in 
 print( a + 12 )
  TypeError: can only concatenate str (not "int") to str


Why doesn't  Python (error msg) do the obvious thing and tell me
WHAT   the actual   (offending,  arg)  values are ?

In many cases, it'd help to know what string the var  A  had  ,   when the 
error occurred.
   i wouldn't have to put  print(a) just above, 
 to see.




( pypydoesn't do that either,   but Python makes programming (debugging) so 
easy that i hardly feel any inconvenience.)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to fix Python error, The term '.../python.exe' is not recognized as the name of a cmdlet, function, script file, or operable program, in VS Code?

2022-10-12 Thread Dennis Lee Bieber
On Tue, 11 Oct 2022 16:40:31 -0700, LouisAden Capellupo
 declaimed the following:

> So basically, I get, "The term '...\python.exe' is not recognized as the 
>name of a cmdlet, function, script, file, or operable program... At line: 1 
>char: 3." It works the first way I showed with Code Runner, but the second or 
>original way doesn't work. What if I don't want to use Code Runner? Any help 
>in fixing this problem would be greatly appreciated. Sorry if certain things 
>are unclear as this is my first time using Python.
>

What happens if you change the system to use the "command" shell
INSTEAD OF PowerShell?

PowerShell may not honor the same environment variables.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to fix Python error, The term '.../python.exe' is not recognized as the name of a cmdlet, function, script file, or operable program, in VS Code?

2022-10-11 Thread Eryk Sun
On 10/11/22, LouisAden Capellupo via Python-list  wrote:
> Variables. 
> C:\Users\It'sMeLil'Loui\AppData\Local\Programs\Python\Python310\Scripts\,
> and C:\Users\It'sMeLil'Loui\AppData\Local\Programs\Python\Python310\.

I suggest that you switch to a user account that doesn't have single
quotes in the name. Using a name that contains single quotes is asking
for trouble. In most command-line shells, which includes PowerShell
(but not CMD), a literal (verbatim) string is contained by single
quotes. The shell usually consumes the quote character if it's not
escaped. See the following sections of the PowerShell documentation:

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.2#single-quoted-strings

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.2#including-quote-characters-in-a-string
-- 
https://mail.python.org/mailman/listinfo/python-list


How to fix Python error, The term '.../python.exe' is not recognized as the name of a cmdlet, function, script file, or operable program, in VS Code?

2022-10-11 Thread LouisAden Capellupo via Python-list
 Hi! I've just downloaded and installed Python 3.10.7 (64-bit) for Windows 
10 from python.org. I'm quite new but, I've already downloaded and installed 
Visual Studio Code as well. I have included the two paths for python under User 
Variables. 
C:\Users\It'sMeLil'Loui\AppData\Local\Programs\Python\Python310\Scripts\, and 
C:\Users\It'sMeLil'Loui\AppData\Local\Programs\Python\Python310\. I verified 
that python is recognized in the Command Prompt and PowerShell and installed 
the necessary extensions for python in Visual Studio Code. I created a test 
python file in the directory of D:\Projects\Python\Test\HelloWorld.py, and 
opened it in Visual Studio Code. I also restarted my laptop after all of this. 
Under the arrow used to run the code, I clicked "Run Code" (since I have Code 
Runner by Jun Han installed), and it worked just fine, displaying the output in 
the terminal.

Code:

print("Hello, world.")
input("Press Enter to continue...")

Output in Terminal when using Code Runner:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\Projects\Python\Test> python -u "d:\Projects\Python\Test\HelloWorld.py"
Hello, world.
Press Enter to continue...
PS D:\Projects\Python\Test> 
However, under the arrow to run code, when I click "Run Python File", I get 
this error message:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Output in Terminal when normally running it:

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\Projects\Python\Test> & 
C:/Users/It'sMeLil'Loui/AppData/Local/Programs/Python/Python310/python.exe 
d:/Projects/Python/Test/HelloWorld.py
& : The term 
'C:/Users/ItsMeLilLoui/AppData/Local/Programs/Python/Python310/python.exe' is 
not recognized as the name of a cmdlet, function, script 
file, or operable program. Check the spelling of the name, or if a path was 
included, verify that the path is correct and try again.
At line:1 char:3
+ & C:/Users/It'sMeLil'Loui/AppData/Local/Programs/Python/Python310/pyt ...
+   ~~~
    + CategoryInfo  : ObjectNotFound: 
(C:/Users/ItsMeL...n310/python.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS D:\Projects\Python\Test>

 So basically, I get, "The term '...\python.exe' is not recognized as the 
name of a cmdlet, function, script, file, or operable program... At line: 1 
char: 3." It works the first way I showed with Code Runner, but the second or 
original way doesn't work. What if I don't want to use Code Runner? Any help in 
fixing this problem would be greatly appreciated. Sorry if certain things are 
unclear as this is my first time using Python.

Thanks, 
LouisAden


Sent from Mail for Windows

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


Re: Python Error

2020-11-24 Thread Mayukh Chakraborty via Python-list
 Thanks.
I updated the path and was able to launch python.exe for v3.8. I got rid of the 
other errors but now facing an error with 'pandas' although  it is installed ok 
and the path correctly updated.
C:\Users\mchak>pythonPython 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) 
[MSC v.1927 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or 
"license" for more information.>>> import pandas as pdTraceback (most recent 
call last):  File "", line 1, in   File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pandas\__init__.py",
 line 22, in     from pandas.compat.numpy import (ModuleNotFoundError: 
No module named 'pandas.compat.numpy'>>>
- Mayukh


On Tuesday, November 24, 2020, 09:27:00 PM GMT, Barry 
 wrote:  
 
 Two observations.

Python.exe is not on your PATH. But that does not matter as you can use the py 
command instead

And nymph may not be available for python 3.9 yet. Check on pypi to see if 
there is a build for 3.9.

Maybe use 3.8 for the time being.
Barry

> On 24 Nov 2020, at 11:18, Mayukh Chakraborty via Python-list 
>  wrote:
> 
>  Thanks - I am able to launch 'py' from the command prompt and it gives me 
> the python versions installed in my machine from python.org website.
> However, when I am trying to execute a python program from command prompt, I 
> am getting the error below. I had reinstalled python packages (numpy, pandas) 
> but it didn't resolve the issue. Any help would be appreciated.
> Original error was: No module named 'numpy.core._multiarray_umath'
> 
> ---
> C:\Users\mchak\Documents\Python>py ES.pyTraceback (most recent call last):  
> File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
>  line 22, in     from . import multiarray  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\multiarray.py",
>  line 12, in     from . import overrides  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\overrides.py",
>  line 7, in     from numpy.core._multiarray_umath import 
> (ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):  File 
> "C:\Users\mchak\Documents\Python\ES.py", line 1, in     import scipy 
> as sp  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scipy\__init__.py",
>  line 61, in     from numpy import show_config as show_numpy_config  
> File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py",
>  line 140, in     from . import core  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
>  line 48, in     raise ImportError(msg)ImportError:
> IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
> Importing the numpy C-extensions failed. This error can happen formany 
> reasons, often due to issues with your setup or how NumPy wasinstalled.
> We have compiled some common reasons and troubleshooting tips at:
>    https://numpy.org/devdocs/user/troubleshooting-importerror.html
> Please note and check the following:
>  * The Python version is: Python3.9 from 
>"C:\Users\mchak\AppData\Local\Programs\Python\Python39\python.exe"  * The 
>NumPy version is: "1.19.4"
> and make sure that they are the versions you expect.Please carefully study 
> the documentation linked above for further help.
> Original error was: No module named 'numpy.core._multiarray_umath'
> 
>>    On Tuesday, November 24, 2020, 07:13:04 AM GMT, Gisle Vanem 
>> wrote:  
>> 
>> Barry Scott wrote:
>> 
>> If you have python from python.org installed you should be able to list all 
>> the version you have installed
>> with the command:
>> 
>>    py -0
> When was that '-0' feature added?
> I have Python 3.6 from Python.org and here a
> 'py.exe -0' gives:
>  Requested Python version (0) not installed
> 
> But using 'py.exe -0' from Python 3.9 correctly
> gives:
>  -3.6-32 *
>  -2.7-32
> 
> -- 
> --gv
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error

2020-11-24 Thread Barry
Two observations.

Python.exe is not on your PATH. But that does not matter as you can use the py 
command instead

And nymph may not be available for python 3.9 yet. Check on pypi to see if 
there is a build for 3.9.

Maybe use 3.8 for the time being.
Barry

> On 24 Nov 2020, at 11:18, Mayukh Chakraborty via Python-list 
>  wrote:
> 
>  Thanks - I am able to launch 'py' from the command prompt and it gives me 
> the python versions installed in my machine from python.org website.
> However, when I am trying to execute a python program from command prompt, I 
> am getting the error below. I had reinstalled python packages (numpy, pandas) 
> but it didn't resolve the issue. Any help would be appreciated.
> Original error was: No module named 'numpy.core._multiarray_umath'
> 
> ---
> C:\Users\mchak\Documents\Python>py ES.pyTraceback (most recent call last):  
> File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
>  line 22, in from . import multiarray  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\multiarray.py",
>  line 12, in from . import overrides  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\overrides.py",
>  line 7, in from numpy.core._multiarray_umath import 
> (ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):  File 
> "C:\Users\mchak\Documents\Python\ES.py", line 1, in import scipy 
> as sp  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scipy\__init__.py",
>  line 61, in from numpy import show_config as show_numpy_config  
> File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py",
>  line 140, in from . import core  File 
> "C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
>  line 48, in raise ImportError(msg)ImportError:
> IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
> Importing the numpy C-extensions failed. This error can happen formany 
> reasons, often due to issues with your setup or how NumPy wasinstalled.
> We have compiled some common reasons and troubleshooting tips at:
> https://numpy.org/devdocs/user/troubleshooting-importerror.html
> Please note and check the following:
>   * The Python version is: Python3.9 from 
> "C:\Users\mchak\AppData\Local\Programs\Python\Python39\python.exe"  * The 
> NumPy version is: "1.19.4"
> and make sure that they are the versions you expect.Please carefully study 
> the documentation linked above for further help.
> Original error was: No module named 'numpy.core._multiarray_umath'
> 
>>On Tuesday, November 24, 2020, 07:13:04 AM GMT, Gisle Vanem 
>>  wrote:  
>> 
>> Barry Scott wrote:
>> 
>> If you have python from python.org installed you should be able to list all 
>> the version you have installed
>> with the command:
>> 
>> py -0
> When was that '-0' feature added?
> I have Python 3.6 from Python.org and here a
> 'py.exe -0' gives:
>   Requested Python version (0) not installed
> 
> But using 'py.exe -0' from Python 3.9 correctly
> gives:
>   -3.6-32 *
>   -2.7-32
> 
> -- 
> --gv
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Re: Python Error

2020-11-24 Thread Mayukh Chakraborty via Python-list
 Thanks - I am able to launch 'py' from the command prompt and it gives me the 
python versions installed in my machine from python.org website.
However, when I am trying to execute a python program from command prompt, I am 
getting the error below. I had reinstalled python packages (numpy, pandas) but 
it didn't resolve the issue. Any help would be appreciated.
Original error was: No module named 'numpy.core._multiarray_umath'

---
C:\Users\mchak\Documents\Python>py ES.pyTraceback (most recent call last):  
File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
 line 22, in     from . import multiarray  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\multiarray.py",
 line 12, in     from . import overrides  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\overrides.py",
 line 7, in     from numpy.core._multiarray_umath import 
(ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):  File 
"C:\Users\mchak\Documents\Python\ES.py", line 1, in     import scipy as 
sp  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scipy\__init__.py",
 line 61, in     from numpy import show_config as show_numpy_config  
File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py",
 line 140, in     from . import core  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
 line 48, in     raise ImportError(msg)ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen formany reasons, 
often due to issues with your setup or how NumPy wasinstalled.
We have compiled some common reasons and troubleshooting tips at:
    https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
  * The Python version is: Python3.9 from 
"C:\Users\mchak\AppData\Local\Programs\Python\Python39\python.exe"  * The NumPy 
version is: "1.19.4"
and make sure that they are the versions you expect.Please carefully study the 
documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'

On Tuesday, November 24, 2020, 07:13:04 AM GMT, Gisle Vanem 
 wrote:  
 
 Barry Scott wrote:

> If you have python from python.org installed you should be able to list all 
> the version you have installed
> with the command:
> 
>    py -0
When was that '-0' feature added?
I have Python 3.6 from Python.org and here a
'py.exe -0' gives:
  Requested Python version (0) not installed

But using 'py.exe -0' from Python 3.9 correctly
gives:
  -3.6-32 *
  -2.7-32

-- 
--gv
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error

2020-11-23 Thread Gisle Vanem

Barry Scott wrote:


If you have python from python.org installed you should be able to list all the 
version you have installed
with the command:

   py -0

When was that '-0' feature added?
I have Python 3.6 from Python.org and here a
'py.exe -0' gives:
  Requested Python version (0) not installed

But using 'py.exe -0' from Python 3.9 correctly
gives:
  -3.6-32 *
  -2.7-32

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error

2020-11-23 Thread Mayukh Chakraborty via Python-list
 Hi,
I have solved the issue by updating the Environment variables, now I am able to 
launch 'py' from the command prompt. However, I can't launch 'python' from 
command prompt. I am also encountering an issue when I try to execute the 
'python' command from command prompt.
I had reinstalled the python packages (numpy, pandas, scipy etc) but I can't 
find a solution for this error.
---
C:\Users\mchak\Documents\Python>py ES.pyTraceback (most recent call last):  
File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
 line 22, in     from . import multiarray  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\multiarray.py",
 line 12, in     from . import overrides  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\overrides.py",
 line 7, in     from numpy.core._multiarray_umath import 
(ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):  File 
"C:\Users\mchak\Documents\Python\ES.py", line 1, in     import scipy as 
sp  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\scipy\__init__.py",
 line 61, in     from numpy import show_config as show_numpy_config  
File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py",
 line 140, in     from . import core  File 
"C:\Users\mchak\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\core\__init__.py",
 line 48, in     raise ImportError(msg)ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen formany reasons, 
often due to issues with your setup or how NumPy wasinstalled.
We have compiled some common reasons and troubleshooting tips at:
    https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
  * The Python version is: Python3.9 from 
"C:\Users\mchak\AppData\Local\Programs\Python\Python39\python.exe"  * The NumPy 
version is: "1.19.4"
and make sure that they are the versions you expect.Please carefully study the 
documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'

Regards,MayukhOn Monday, November 23, 2020, 08:17:06 PM GMT, Mayukh 
Chakraborty via Python-list  wrote:  
 
  Hi Terry,
1. The command py doesn't work. It gives me the error below :
C:\Users\mchak>pyFatal Python error: init_sys_streams: can't initialize sys 
standard streamsPython runtime state: core initializedAttributeError: module 
'io' has no attribute 'open'
Current thread 0x8290 (most recent call first):

2. If I use py -0, I get two installed versions. However, if I try to uninstall 
from Control Panel, I see only 3.9 version
C:\Users\mchak>py -0Installed Pythons found by py Launcher for Windows -3.9-64 
* -3.8-64
3. I tried to uninstall v3.9 and reinstall but it didn't solve the issue.
Regards,Mayukh    On Monday, November 23, 2020, 06:34:43 PM GMT, Terry Reedy 
 wrote:  
 
 On 11/23/2020 9:10 AM, Mayukh Chakraborty via Python-list wrote:
> Hi,
> I had uninstalled and installed Python in Windows 10 but I am getting the 
> error below. Can you please help ?
> C:\Users\mchak>python
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
AttributeError: module 'io' has no attribute 'OpenWrapper'
Current thread 0x9d44 (most recent call first):

It is true that io has no OpenWrapper class.  The question is What is 
trying to use that?  What installer are you using?  I would 
(re)download the one from python.org.
-- 
Terry Jan Reedy

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


Re: Python Error

2020-11-23 Thread Mayukh Chakraborty via Python-list
 Hi Terry,
1. The command py doesn't work. It gives me the error below :
C:\Users\mchak>pyFatal Python error: init_sys_streams: can't initialize sys 
standard streamsPython runtime state: core initializedAttributeError: module 
'io' has no attribute 'open'
Current thread 0x8290 (most recent call first):

2. If I use py -0, I get two installed versions. However, if I try to uninstall 
from Control Panel, I see only 3.9 version
C:\Users\mchak>py -0Installed Pythons found by py Launcher for Windows -3.9-64 
* -3.8-64
3. I tried to uninstall v3.9 and reinstall but it didn't solve the issue.
Regards,MayukhOn Monday, November 23, 2020, 06:34:43 PM GMT, Terry Reedy 
 wrote:  
 
 On 11/23/2020 9:10 AM, Mayukh Chakraborty via Python-list wrote:
> Hi,
> I had uninstalled and installed Python in Windows 10 but I am getting the 
> error below. Can you please help ?
> C:\Users\mchak>python
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
AttributeError: module 'io' has no attribute 'OpenWrapper'
Current thread 0x9d44 (most recent call first):

It is true that io has no OpenWrapper class.  The question is What is 
trying to use that?  What installer are you using?  I would 
(re)download the one from python.org.
-- 
Terry Jan Reedy

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


Re: Python Error

2020-11-23 Thread Mayukh Chakraborty via Python-list
 1. The command 'py' doesn't work. It gives me the error below :
C:\Users\mchak>pyFatal Python error: init_sys_streams: can't initialize sys 
standard streamsPython runtime state: core initializedAttributeError: module 
'io' has no attribute 'open'
Current thread 0x8290 (most recent call first):

2. If I use py -0, I get two installed versions. However, if I try to uninstall 
from Control Panel, I see only 3.9 version
C:\Users\mchak>py -0Installed Pythons found by py Launcher for Windows -3.9-64 
* -3.8-64
3. I tried to uninstall v3.9 and reinstall but it didn't solve the issue.
Regards,Mayukh
On Monday, November 23, 2020, 06:17:00 PM GMT, Barry Scott 
 wrote:  
 
 

> On 23 Nov 2020, at 14:10, Mayukh Chakraborty via Python-list 
>  wrote:
> 
> Hi,
> I had uninstalled and installed Python in Windows 10 but I am getting the 
> error below. Can you please help ?
> C:\Users\mchak>pythonFatal Python error: init_sys_streams: can't initialize 
> sys standard streamsPython runtime state: core initializedAttributeError: 
> module 'io' has no attribute 'OpenWrapper'
> Current thread 0x9d44 (most recent call first):
> Regards,Mayukh

Which version of python are you installing and where did you download it from?
Do you have more than one version of python installed?


Does the command:

  py

work?

If you have python from python.org installed you should be able to list all the 
version you have installed
with the command:

  py -0

That is zero not oh.

Barry




> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error

2020-11-23 Thread Terry Reedy

On 11/23/2020 9:10 AM, Mayukh Chakraborty via Python-list wrote:

Hi,
I had uninstalled and installed Python in Windows 10 but I am getting the error 
below. Can you please help ?
C:\Users\mchak>python

Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
AttributeError: module 'io' has no attribute 'OpenWrapper'
Current thread 0x9d44 (most recent call first):

It is true that io has no OpenWrapper class.  The question is What is 
trying to use that?   What installer are you using?  I would 
(re)download the one from python.org.

--
Terry Jan Reedy

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


Re: Python Error

2020-11-23 Thread Barry Scott



> On 23 Nov 2020, at 14:10, Mayukh Chakraborty via Python-list 
>  wrote:
> 
> Hi,
> I had uninstalled and installed Python in Windows 10 but I am getting the 
> error below. Can you please help ?
> C:\Users\mchak>pythonFatal Python error: init_sys_streams: can't initialize 
> sys standard streamsPython runtime state: core initializedAttributeError: 
> module 'io' has no attribute 'OpenWrapper'
> Current thread 0x9d44 (most recent call first):
> Regards,Mayukh

Which version of python are you installing and where did you download it from?
Do you have more than one version of python installed?


Does the command:

   py

work?

If you have python from python.org installed you should be able to list all the 
version you have installed
with the command:

  py -0

That is zero not oh.

Barry




> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Python Error

2020-11-23 Thread Mayukh Chakraborty via Python-list
Hi,
I had uninstalled and installed Python in Windows 10 but I am getting the error 
below. Can you please help ?
C:\Users\mchak>pythonFatal Python error: init_sys_streams: can't initialize sys 
standard streamsPython runtime state: core initializedAttributeError: module 
'io' has no attribute 'OpenWrapper'
Current thread 0x9d44 (most recent call first):
Regards,Mayukh
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python error

2020-04-02 Thread MRAB

On 2020-04-02 19:09, J Conrado wrote:

Hi,

I have the version of python installed:
Python 3.7.6 and Python 3.8.1
If I type:
python
Python 3.7.6 (default, Jan  8 2020, 19:59:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
  >>> import numpy

it is Ok, no error, but if I did:

python3.8

Python 3.8.1 (default, Jan 31 2020, 15:49:05)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
  >>> import numpy

Traceback (most recent call last):
    File "", line 1, in 
ModuleNotFoundError: No module named 'numpy'

Please,
I would like to know why in the python3.8 version I have this error.


Thanks,

It looks like you have the Anaconda distribution for Python 3.7 and the 
standard distribution for Python 3.8.

The standard distribution comes with only the standard library.

The Anaconda distribution comes with a lot of extra stuff, which 
includes numpy.

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


Re: Python error

2020-04-02 Thread Mirko via Python-list
Am 02.04.2020 um 20:09 schrieb J Conrado:
> Hi,
> 
> I have the version of python installed:
> Python 3.7.6 and Python 3.8.1
> If I type:
> python
> Python 3.7.6 (default, Jan  8 2020, 19:59:22)
> [GCC 7.3.0] :: Anaconda, Inc. on linux
> Type "help", "copyright", "credits" or "license" for more information.
 import numpy
> 
> it is Ok, no error, but if I did:
> 
> python3.8
> 
> Python 3.8.1 (default, Jan 31 2020, 15:49:05)
> [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
> Type "help", "copyright", "credits" or "license" for more information.
 import numpy
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> ModuleNotFoundError: No module named 'numpy'
> 
> Please,
> I would like to know why in the python3.8 version I have this error.


Because you installed numpy only for 3.7.6. All Python installations
have their own module paths, so you need to install numpy for 3.8.1
too. Do it with:

python3.8 -m pip install numpy
-- 
https://mail.python.org/mailman/listinfo/python-list


Python error

2020-04-02 Thread J Conrado

Hi,

I have the version of python installed:
Python 3.7.6 and Python 3.8.1
If I type:
python
Python 3.7.6 (default, Jan  8 2020, 19:59:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy

it is Ok, no error, but if I did:

python3.8

Python 3.8.1 (default, Jan 31 2020, 15:49:05)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy

Traceback (most recent call last):
  File "", line 1, in 
ModuleNotFoundError: No module named 'numpy'

Please,
I would like to know why in the python3.8 version I have this error.


Thanks,


Conrado

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


Re: Python Error Still Occured on sklearn

2019-12-02 Thread Maisarah
Thank you.





Maisarah Binti Mohd Yusak


Certified CPRE-FL & CTFL

Software Tester, IT Team.



AVL Infotech (Malaysia) Sdn. Bhd.



 



L2-I-3, Enterprise - 4 , Technology Park Malaysia,
Bukit Jalil, Kuala Lumpur, Malaysia -57000
Mobile: +6016 507 3051
Mail: mailto:maisa...@avlinfotech.net

LinkedIn: https://my.linkedin.com/in/maimoyu

Web: http://www.avlinfotech.net/










 On Mon, 02 Dec 2019 17:30:24 +0800 Maisarah  
wrote 


Dear Admin,



I have install and upgrade Cython as well. 

I have modified and repaired and even update the library but error is still 
occurred:



C:\Windows\system32>pip install -U scikit-learn 

Collecting scikit-learn

  Using cached 
https://files.pythonhosted.org/packages/1e/ce/9d8c88e68af0a5b5c5d78d8d2b7bcadfd45e1d6afc863ccb9aee30765b06/scikit-learn-0.21.3.tar.gz

Requirement already satisfied, skipping upgrade: numpy>=1.11.0 in 
c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from 
scikit-learn) (1.17.4)

Requirement already satisfied, skipping upgrade: scipy>=0.17.0 in 
c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from 
scikit-learn) (1.3.3)

Requirement already satisfied, skipping upgrade: joblib>=0.11 in 
c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from 
scikit-learn) (0.14.0)

Installing collected packages: scikit-learn

    Running setup.py install for scikit-learn ... error

    ERROR: Command errored out with exit status 1:

 command: 'c:\users\user\appdata\local\programs\python\python38\python.exe' 
-u -c 'import sys, setuptools, tokenize; sys.argv[0] = 
'"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-caioz9bv\\scikit-learn\\setup.py'"'"';
 
__file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-caioz9bv\\scikit-learn\\setup.py'"'"';f=getattr(tokenize,
 '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install 
--record 
'C:\Users\user\AppData\Local\Temp\pip-record-o9y5q4bk\install-record.txt' 
--single-version-externally-managed --compile

 cwd: 
C:\Users\user\AppData\Local\Temp\pip-install-caioz9bv\scikit-learn\

    Complete output (44 lines):

    Partial import of sklearn during the build process.

    No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying 
from distutils

    Traceback (most recent call last):

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\site-packages\setuptools\msvc.py",
 line 489, in _find_latest_available_vc_ver

    return self.find_available_vc_vers()[-1]

    IndexError: list index out of range



    During handling of the above exception, another exception occurred:



    Traceback (most recent call last):

  File "", line 1, in 

  File 
"C:\Users\user\AppData\Local\Temp\pip-install-caioz9bv\scikit-learn\setup.py", 
line 290, in 

    setup_package()

  File 
"C:\Users\user\AppData\Local\Temp\pip-install-caioz9bv\scikit-learn\setup.py", 
line 286, in setup_package

    setup(**metadata)

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\site-packages\numpy\distutils\core.py",
 line 137, in setup

    config = configuration()

  File 
"C:\Users\user\AppData\Local\Temp\pip-install-caioz9bv\scikit-learn\setup.py", 
line 174, in configuration

    config.add_subpackage('sklearn')

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\site-packages\numpy\distutils\misc_util.py",
 line 1033, in add_subpackage

    config_list = self.get_subpackage(subpackage_name, subpackage_path,

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\site-packages\numpy\distutils\misc_util.py",
 line 999, in get_subpackage

    config = self._get_configuration_from_setup_py(

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\site-packages\numpy\distutils\misc_util.py",
 line 941, in _get_configuration_from_setup_py

    config = setup_module.configuration(*args)

  File "sklearn\setup.py", line 76, in configuration

    maybe_cythonize_extensions(top_path, config)

  File 
"C:\Users\user\AppData\Local\Temp\pip-install-caioz9bv\scikit-learn\sklearn\_build_utils\__init__.py",
 line 42, in maybe_cythonize_extensions

    with_openmp = check_openmp_support()

  File 
"C:\Users\user\AppData\Local\Temp\pip-install-caioz9bv\scikit-learn\sklearn\_build_utils\openmp_helpers.py",
 line 83, in check_openmp_support

    ccompiler.compile(['test_openmp.c'], output_dir='objects',

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\distutils\_msvccompiler.py",
 line 360, in compile

    self.initialize()

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\distutils\_msvccompiler.py",
 line 253, in initialize

    vc_env = _get_vc_env(plat_spec)

  File 
"c:\users\user\appdata\local\programs\python\python38\lib\site-pac

Re: Fatal Python error

2019-01-27 Thread songbird
Abdallah Adham wrote:
> Hey
> I am having this problem for about 2 weeks, I can't do anything, so please
> give me some instructions so I can solve it.
>
> Fatal Python error: initfsencoding: unable to load the file system code.
> ModuleNotFoundError: No module named 'encodings'
>
>:Current thread 0x3c7c (most recent call first
>
> Process finished with exit code -1073740791 (0xC409)

  
https://stackoverflow.com/questions/54087049/fatal-python-error-initfsencoding-unable-to-load-the-file-system-codec


  songbird
-- 
https://mail.python.org/mailman/listinfo/python-list


Fatal Python error

2019-01-27 Thread Abdallah Adham
Hey
I am having this problem for about 2 weeks, I can't do anything, so please
give me some instructions so I can solve it.

Fatal Python error: initfsencoding: unable to load the file system code.
ModuleNotFoundError: No module named 'encodings'

:Current thread 0x3c7c (most recent call first

Process finished with exit code -1073740791 (0xC409)

 Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-22 Thread Tim Williams
On Friday, December 22, 2017 at 8:41:29 AM UTC-5, Tim Williams wrote:
> On Thursday, December 21, 2017 at 12:18:11 PM UTC-5, MarkA wrote:
> > On Thu, 21 Dec 2017 07:05:33 -0800, rafaeltfreire wrote:
> > From docs.python.org:
> > 
> > 8.10. copy — Shallow and deep copy operations
> > 
> > Source code: Lib/copy.py
> > 
> > Assignment statements in Python do not copy objects, they create bindings 
> > between a target and an object. For collections that are mutable or 
> > contain mutable items, a copy is sometimes needed so one can change one 
> > copy without changing the other. This module provides generic shallow and 
> > deep copy operations (explained below)...
> > 
> > 
> > > Dear community, I am having the following problem when I am assigning
> > > the elements of a vector below a certain number to zero or any other
> > > value.
> > > I am creating a new variable but Python edits the root variable. Why?
> > > 
> > > import numpy as np
> > > 
> > > X=np.arange(1, 1, 1) #root variable x1=X x1[x1<1]=0
> > > 
> > > print(X)
> > > Out[1]: array([ 0.,  0.,  0., ...,  0.,  0.,  0.])
> > > 
> > > Why? It is supposed to be the original value Thank you for your
> > > time Rafael
> > 
> > 
> > 
> > -- 
> > MarkA
> > 
> > We hang petty theives, and appoint the great theives to public office
> >   -- Aesop
> 
> Shouldn't the OP just create a list for what he want's to do?
> 
> X = list(np.arange(1, 1, 1)) #root variable x1=X x1[x1<1]=0
> 
> Then I think his other statements would do what he expects, no?

Disregard what I just posted. I didn't think this through enough. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-22 Thread Tim Williams
On Thursday, December 21, 2017 at 12:18:11 PM UTC-5, MarkA wrote:
> On Thu, 21 Dec 2017 07:05:33 -0800, rafaeltfreire wrote:
> From docs.python.org:
> 
> 8.10. copy — Shallow and deep copy operations
> 
> Source code: Lib/copy.py
> 
> Assignment statements in Python do not copy objects, they create bindings 
> between a target and an object. For collections that are mutable or 
> contain mutable items, a copy is sometimes needed so one can change one 
> copy without changing the other. This module provides generic shallow and 
> deep copy operations (explained below)...
> 
> 
> > Dear community, I am having the following problem when I am assigning
> > the elements of a vector below a certain number to zero or any other
> > value.
> > I am creating a new variable but Python edits the root variable. Why?
> > 
> > import numpy as np
> > 
> > X=np.arange(1, 1, 1) #root variable x1=X x1[x1<1]=0
> > 
> > print(X)
> > Out[1]: array([ 0.,  0.,  0., ...,  0.,  0.,  0.])
> > 
> > Why? It is supposed to be the original value Thank you for your
> > time Rafael
> 
> 
> 
> -- 
> MarkA
> 
> We hang petty theives, and appoint the great theives to public office
>   -- Aesop

Shouldn't the OP just create a list for what he want's to do?

X = list(np.arange(1, 1, 1)) #root variable x1=X x1[x1<1]=0

Then I think his other statements would do what he expects, no?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-21 Thread duncan smith
On 21/12/17 19:06, John Ladasky wrote:
> On Thursday, December 21, 2017 at 7:37:39 AM UTC-8, MRAB wrote:
> 
>> Python never makes a copy unless you ask it to.
>>
>> What x1=X does is make the name x1 refer to the same object that X 
>> refers to. No copying.
> 
> Well, except with very simple, mutable data types like scalars... compare 
> this:
> 
 x=5
 y=x
 x,y
> (5, 5)
 x+=1
 x,y
> (6, 5)
> 
> To this:
> 
 a=[1,2,3]
 b=a
 a,b
> ([1, 2, 3], [1, 2, 3])
 a[1]=9
 a,b
> ([1, 9, 3], [1, 9, 3])
> 

Except ints aren't mutable and there's still no copying.

For

x += 1

(where x is e.g. an int) read

x = x + 1

Duncan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-21 Thread Kirill Balunov
2017-12-21 22:06 GMT+03:00 John Ladasky :

> On Thursday, December 21, 2017 at 7:37:39 AM UTC-8, MRAB wrote:
>
> > Python never makes a copy unless you ask it to.
> >
> > What x1=X does is make the name x1 refer to the same object that X
> > refers to. No copying.
>
> Well, except with very simple, mutable data types like scalars... compare
> this:
>

No copy means no copy, it is the rule! What you see is really new binding
operation under the hood.
'x=1; x += 1', means calculate x+1 and bind it to the same name. Compare it
to this example:


>>> tpl = ((1,2),(3,4))
>>> tpl += ((1,2),)
>>> tpl

((1, 2), (3, 4), (1, 2))


No copy, new binding to the same name :)


With kind regards, -gdg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-21 Thread John Ladasky
On Thursday, December 21, 2017 at 7:37:39 AM UTC-8, MRAB wrote:

> Python never makes a copy unless you ask it to.
> 
> What x1=X does is make the name x1 refer to the same object that X 
> refers to. No copying.

Well, except with very simple, mutable data types like scalars... compare this:

>>> x=5
>>> y=x
>>> x,y
(5, 5)
>>> x+=1
>>> x,y
(6, 5)

To this:

>>> a=[1,2,3]
>>> b=a
>>> a,b
([1, 2, 3], [1, 2, 3])
>>> a[1]=9
>>> a,b
([1, 9, 3], [1, 9, 3])

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


Re: Problem with assignment. Python error or mine?

2017-12-21 Thread MarkA
On Thu, 21 Dec 2017 07:05:33 -0800, rafaeltfreire wrote:
From docs.python.org:

8.10. copy — Shallow and deep copy operations

Source code: Lib/copy.py

Assignment statements in Python do not copy objects, they create bindings 
between a target and an object. For collections that are mutable or 
contain mutable items, a copy is sometimes needed so one can change one 
copy without changing the other. This module provides generic shallow and 
deep copy operations (explained below)...


> Dear community, I am having the following problem when I am assigning
> the elements of a vector below a certain number to zero or any other
> value.
> I am creating a new variable but Python edits the root variable. Why?
> 
> import numpy as np
> 
> X=np.arange(1, 1, 1) #root variable x1=X x1[x1<1]=0
> 
> print(X)
> Out[1]: array([ 0.,  0.,  0., ...,  0.,  0.,  0.])
> 
> Why? It is supposed to be the original value Thank you for your
> time Rafael



-- 
MarkA

We hang petty theives, and appoint the great theives to public office
  -- Aesop
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-21 Thread MRAB

On 2017-12-21 15:05, rafaeltfre...@gmail.com wrote:

Dear community, I am having the following problem when I am assigning the 
elements of a vector below a certain number to zero or any other value.
I am creating a new variable but Python edits the root variable. Why?

import numpy as np

X=np.arange(1, 1, 1) #root variable
x1=X
x1[x1<1]=0

print(X)
Out[1]: array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

Why? It is supposed to be the original value
Thank you for your time
Rafael


Python never makes a copy unless you ask it to.

What x1=X does is make the name x1 refer to the same object that X 
refers to. No copying.


As you're using numpy, you can use the .copy method:

x1 = X.copy()

This makes the name x1 refer to a new copy of the object that X refers to.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-21 Thread rafaeltfreire
Em quinta-feira, 21 de dezembro de 2017 16:21:57 UTC+1, Neil Cerutti  escreveu:
> On 2017-12-21, rafaeltfre...@gmail.com  wrote:
> > Dear community, I am having the following problem when I am
> > assigning the elements of a vector below a certain number to
> > zero or any other value. I am creating a new variable but
> > Python edits the root variable. Why?
> >
> > import numpy as np
> >
> > X=np.arange(1, 1, 1) #root variable
> 
> np.arange creates an object. The assignment makes X refer to that
> object.
> 
> > x1=X 
> 
> X refers to the previous object, and then the assignment makes x1
> refer to that same object.
> 
> -- 
> Neil Cerutti

Ok, great thank you. I am kind of new in python. I use to program in MATLAB but 
I am trying to migrate. 
So, to fix it what should I do? because my X is an NMR spectrum of many 
samples. 
Thank you very much!
Rafael
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem with assignment. Python error or mine?

2017-12-21 Thread Neil Cerutti
On 2017-12-21, rafaeltfre...@gmail.com  wrote:
> Dear community, I am having the following problem when I am
> assigning the elements of a vector below a certain number to
> zero or any other value. I am creating a new variable but
> Python edits the root variable. Why?
>
> import numpy as np
>
> X=np.arange(1, 1, 1) #root variable

np.arange creates an object. The assignment makes X refer to that
object.

> x1=X 

X refers to the previous object, and then the assignment makes x1
refer to that same object.

-- 
Neil Cerutti

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


Problem with assignment. Python error or mine?

2017-12-21 Thread rafaeltfreire
Dear community, I am having the following problem when I am assigning the 
elements of a vector below a certain number to zero or any other value. 
I am creating a new variable but Python edits the root variable. Why?

import numpy as np

X=np.arange(1, 1, 1) #root variable
x1=X 
x1[x1<1]=0

print(X)
Out[1]: array([ 0.,  0.,  0., ...,  0.,  0.,  0.])

Why? It is supposed to be the original value
Thank you for your time
Rafael
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error

2017-01-16 Thread Terry Reedy

On 1/16/2017 12:32 AM, Girish Khasnis wrote:

Hi,


I am unable to install Python on my system. After installing Python I get
the below error when I try to open Python.

[image: Inline image 1]


Copy and paste the error message.  This is text only list.


--
Terry Jan Reedy

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


Python Error

2017-01-16 Thread Girish Khasnis
Hi,


I am unable to install Python on my system. After installing Python I get
the below error when I try to open Python.

[image: Inline image 1]

Regards
Girish
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: import pybel in python error code

2016-09-09 Thread Peter Otten
talari.gopiprashanth.go...@gmail.com wrote:

> ValueErrorTraceback (most recent call
> last)  in ()
>   1 from django.conf import settings
> > 2 import pybel
>   3 import random, os
> 
> C:\Miniconda2\lib\site-packages\pybel.py in ()
>  67 _obconv = ob.OBConversion()
>  68 _builder = ob.OBBuilder()
> ---> 69 informats = _formatstodict(_obconv.GetSupportedInputFormat())
>  70 """A dictionary of supported input formats"""
>  71 outformats = _formatstodict(_obconv.GetSupportedOutputFormat())
> 
> C:\Miniconda2\lib\site-packages\pybel.py in _formatstodict(list)
>  63 list = [list.get(i) for i in range(list.size())]
>  64 broken = [x.replace("[Read-only]",
>  "").replace("[Write-only]","").split(" -- ") for x in list]
> ---> 65 broken = [(x,y.strip()) for x,y in broken]
>  66 return dict(broken)
>  67 _obconv = ob.OBConversion()
> 
> ValueError: need more than 1 value to unpack

What does

>>> import openbabel
>>> [s for s in openbabel.OBConversion().GetSupportedInputFormat()
...  if s.count(" -- ") != 1]
[]

print on your machine? There is probably a string that doesn't contain the 
separator " -- " (note the space at the beginning and the end).


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


import pybel in python error code

2016-09-09 Thread talari . gopiprashanth . gopi2
ValueErrorTraceback (most recent call last)
 in ()
  1 from django.conf import settings
> 2 import pybel
  3 import random, os

C:\Miniconda2\lib\site-packages\pybel.py in ()
 67 _obconv = ob.OBConversion()
 68 _builder = ob.OBBuilder()
---> 69 informats = _formatstodict(_obconv.GetSupportedInputFormat())
 70 """A dictionary of supported input formats"""
 71 outformats = _formatstodict(_obconv.GetSupportedOutputFormat())

C:\Miniconda2\lib\site-packages\pybel.py in _formatstodict(list)
 63 list = [list.get(i) for i in range(list.size())]
 64 broken = [x.replace("[Read-only]", 
"").replace("[Write-only]","").split(" -- ") for x in list]
---> 65 broken = [(x,y.strip()) for x,y in broken]
 66 return dict(broken)
 67 _obconv = ob.OBConversion()

ValueError: need more than 1 value to unpack
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2016-08-31 Thread eryk sun
On Wed, Aug 31, 2016 at 9:04 AM, Wanderer <864483...@qq.com> wrote:
> The system environment I alse configured.The Sigil project also build 
> successed.
> But When I run the Sigil.exe that follow errors occured.
> ------
> Fatal Python error: Py_Initialize: unable to load the file system codec
> --

This is an expected error if Python can't find the standard library.
For example:

C:\>cmd /c "set PYTHONHOME=C:\ & python"
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Current thread 0x0730 (most recent call first):

Maybe you have a stale PYTHONHOME setting (generally this variable
should not be set permanently), or maybe you've put the standard
library (possibly python36.zip) somewhere unexpected.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fatal Python error

2016-08-31 Thread Wanderer
Dear friendI'm very sorry to bother you in a busy schedule.
But I have a questions about Sigil's environment that really need your help.


I'm trying to use Sigil at a windows system,the follow are the relation of 
Sigil build and run environment.


OS:WIN10
Python:python-3.6.0a4-amd64
QT:qt5.5.1
ActivePerl:ActivePerl-5.24.0.2400-MSWin32-x64-300558
Ruby:rubyinstaller-2.3.1-x64
Sigil:Sigil-0.9.6-Code
VS:VS2015


The system environment I alse configured.The Sigil project also build successed.
But When I run the Sigil.exe that follow errors occured.
------
Fatal Python error: Py_Initialize: unable to load the file system codec
--


The Sigil.exe can not run, and the main sigil form also can not appearses.


Can you help me which I should do to solove this problems?


Thanks very much.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error message

2016-08-05 Thread dieter
GBANE FETIGUE  writes:
> ...
> I am running a python script to run some CURL commands, and return the 
> response which is the applicationId and the versionId. I was able to do it. 
> Now the versionId value supposed to be used on the second CURL as a value of 
> the applications key which is an array. but it doesn't work.I 'll post the 
> error after running the command as well as the script. It seems like I have 
> an error somewhere because the curl works manually if i run. 
>
> ec2-user@ip-172-31-21-77 playbooks]$ python mmc-uploader.py
> ...
> Final response...HTTP Status 415 -  class="
>  line">type Status reportmessage 
> description The server refused this request because 
> the request entity is in a format not supported by the reque
>  sted resource for the requested method.Apache 
> Tomcat/8.0.26

What you see here is *not* a Python error message but an
error message from the server you have contacted.
It tells you:
"The server refused this request because the request entity is in a format not 
supported by the requested resource for the requested method."

This means, that in constructing your request you made some error - regarding
the "format" (which may mean the "Content-Type") for
the request "entity" (which may mean the request body).

I would check the service description to find out about what
"format" is expected and what the term "entity" means.
Then I would check the "curl" documentation to find out how to meet
those expectations.

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


Re: Python Error message

2016-08-04 Thread Chris Angelico
On Fri, Aug 5, 2016 at 5:36 AM, Terry Reedy  wrote:
> An example of the latter is when one writes code in Python to execute
> 'other' code.  (IDLE is one example.  It both executes user statements and
> evals user expressions.)  One needs "except BaseException:"  to isolate the
> interpreter from exceptions raised in the interpreted code. (It would be
> wrong for IDLE to stop because a user submitted code that raises, whether
> intentionally or accidentally)  A 'raise' that throws the exception into the
> interpreter is likely the worst thing to do.

This is a classic example of a "boundary location". Another extremely
common example is a web server: if an exception bubbles out of a
request handler function, the outer wrapper code should catch that,
log it, and send a 500 back to the client.

But none of this is what the OP is doing.

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


Re: Python Error message

2016-08-04 Thread Terry Reedy

On 8/4/2016 12:19 PM, MRAB wrote:


In those rare occasions when you do write a bare except,


A bare "except:" is never needed and in my opinion, and that of others, 
one should never write one (except possibly for experimentation). Be 
explicit and write "except BaseException:" or "except Exception:", 
whichever one is the actual intent.


> you'd re-raise the exception afterwards:

As a general rule, this is wrong, just as this rule is wrong for other 
exception blocks.



try:
...
except:
print("'tis but a scratch!")
raise


This is right when one wants to do something *in addition to* the normal 
handling, such as log errors to a file, but is wrong when wants to do 
something *instead of* allowing the normal handling.


An example of the latter is when one writes code in Python to execute 
'other' code.  (IDLE is one example.  It both executes user statements 
and evals user expressions.)  One needs "except BaseException:"  to 
isolate the interpreter from exceptions raised in the interpreted code. 
(It would be wrong for IDLE to stop because a user submitted code that 
raises, whether intentionally or accidentally)  A 'raise' that throws 
the exception into the interpreter is likely the worst thing to do.


--
Terry Jan Reedy

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


Re: Python Error message

2016-08-04 Thread Chris Angelico
On Fri, Aug 5, 2016 at 2:09 AM, Igor Korot  wrote:
>> [1] There are exceptions to this rule, for experts. But if you need to ask
>> what they are, you're not ready to know
>
> But even the experts will never write such a code - you never know what 
> happens
> in a month. Server might throw some new exception, you may move on to
> a different project,
> etc, etc. ;-)

Yes, in those situations you don't write a bare except :) As Steven
said, there ARE legit uses; most of them fall under the description
"boundary location".

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


Re: Python Error message

2016-08-04 Thread MRAB

On 2016-08-04 17:09, Igor Korot wrote:

Steven,

On Thu, Aug 4, 2016 at 11:56 AM, Steven D'Aprano
 wrote:

On Fri, 5 Aug 2016 01:31 am, GBANE FETIGUE wrote:


try:
  parsed_response = json.loads(response)
  deployid  = parsed_response[u'id']
  print "Your deployid is: " + deployid
except:
print 'Seems the named id  already exists!'



I'm not going to try to debug your code blindfolded with my hands tied
behind my back. Get rid of those "try...except" blocks so that you can see
what error is *actually* happening.

As you have it now, an error happens, somewhere. You don't know where the
error is, or what it is, but Python generates a nice exception showing all
the detail you need to debug.

But you catch that exception, throw it away, and then print a lie.

It is **not true** that the named ID already exists. That is not what the
error is, so why does your script tell a lie?

The output from the server might give you a clue:

"The server refused this request because the request entity is in a format
not supported by the requested resource for the requested method."


Never[1] use a bare "try...except". It is the worst thing you can do to a
Python script, making it almost impossible to debug.

https://realpython.com/blog/python/the-most-diabolical-python-antipattern/

Fix that problem first, get rid of the "try...except" and lying print
messages, and then either the bug will be obvious, or we can debug further.






[1] There are exceptions to this rule, for experts. But if you need to ask
what they are, you're not ready to know


But even the experts will never write such a code - you never know what happens
in a month. Server might throw some new exception, you may move on to
a different project,
etc, etc. ;-)

In those rare occasions when you do write a bare except, you'd re-raise 
the exception afterwards:


try:
...
except:
print("'tis but a scratch!")
raise


Thank you.



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


Re: Python Error message

2016-08-04 Thread MRAB

On 2016-08-04 16:31, GBANE FETIGUE wrote:

Hi,
I am running a python script to run some CURL commands, and return the response 
which is the applicationId and the versionId. I was able to do it. Now the 
versionId value supposed to be used on the second CURL as a value of the 
applications key which is an array. but it doesn't work.I 'll post the error 
after running the command as well as the script. It seems like I have an error 
somewhere because the curl works manually if i run.


What do you put on the command line when you do it manually?


ec2-user@ip-172-31-21-77 playbooks]$ python mmc-uploader.py
  % Total% Received % Xferd  Average Speed   TimeTime Time  Current
 Dload  Upload   Total   SpentLeft  Speed
100  23180   119  100  2199496   9173 --:--:-- --:--:-- --:--:--  9200
Your applicationId is: local$fc9277b0-a5b1-4602-8730-714ab7472744
Your versionId is: local$423da1c8-c4e1-47af-9395-57300f839670
  % Total% Received % Xferd  Average Speed   TimeTime Time  Current
 Dload  Upload   Total   SpentLeft  Speed
100  1259  100  1091  100   168   100k  15868 --:--:-- --:--:-- --:--:--  106k
Final responseApache Tomcat/8.0.26 - Error reportH1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY 
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name 
{color : black;}.line {height: 1px; background-color: #525D76; border: none;} HTTP Status 415 - type Status 
reportmessage description The server refused this request because the request entity is in a format not supported by the req

ue

 sted resource for the requested method.Apache 
Tomcat/8.0.26
Seems the named id  already exists!

That's the script :

from subprocess import check_output, STDOUT
import json

response = check_output(["curl", "--basic", "-u", "admin:admin", "-F", 
"file=@/var/lib/jenkins/workspace/Demo-Ci-cd-automation/playbooks/ms3-simple-hello-world-app-1.0.0-SNAPSHOT.zip", "-F", "name=ms3-simple-hello-world-app", "-F", 
"version=1.0.0", "--header", "\"Content-Type: multipart/form-data\"", "http://52.73.56.141:8080/mmc-console-3.6.2/api/repository";])


try:
parsed_response = json.loads(response)
print "Your applicationId is: " + parsed_response[u'applicationId']
version_id = parsed_response[u'versionId']
print "Your versionId is: " + version_id


Don't use a bare except because it'll catch _ANY_ exception, including 
NameError, which could happen if you accidentally misspell a name.



except:
print 'Seems the named application already exists!'
print 'Seems the named versionId already exists!'

This look likes it passes curl some JSON wrapped in "'", so curl won't 
see something like this:


{"key": "value"}

(a dict), it'll see something like this:

'{"key": "value"}'

(a string delimited by '...') which isn't valid JSON.


response = check_output(["curl", "--basic", "-u", "admin:admin", "-d", "'{\"name\" : \"ms3-simple-hello-world-app\" , \"servers\": [ 
\"local$d50bdc24-ff04-4327-9284-7bb708e21c25\" ], \"applications\": [ \"" + version_id +  "\"]}'", "--header", "\'Content-Type: application/json\'", 
"http://52.73.56.141:8080/mmc-console-3.6.2/api/deployments";])

print 'Final response' + response

try:
  parsed_response = json.loads(response)
  deployid  = parsed_response[u'id']
  print "Your deployid is: " + deployid


Another bare except!


except:
print 'Seems the named id  already exists!'


'check_output' and related functions/methods will do the quoting for you.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error message

2016-08-04 Thread Igor Korot
Steven,

On Thu, Aug 4, 2016 at 11:56 AM, Steven D'Aprano
 wrote:
> On Fri, 5 Aug 2016 01:31 am, GBANE FETIGUE wrote:
>
>> try:
>>   parsed_response = json.loads(response)
>>   deployid  = parsed_response[u'id']
>>   print "Your deployid is: " + deployid
>> except:
>> print 'Seems the named id  already exists!'
>
>
> I'm not going to try to debug your code blindfolded with my hands tied
> behind my back. Get rid of those "try...except" blocks so that you can see
> what error is *actually* happening.
>
> As you have it now, an error happens, somewhere. You don't know where the
> error is, or what it is, but Python generates a nice exception showing all
> the detail you need to debug.
>
> But you catch that exception, throw it away, and then print a lie.
>
> It is **not true** that the named ID already exists. That is not what the
> error is, so why does your script tell a lie?
>
> The output from the server might give you a clue:
>
> "The server refused this request because the request entity is in a format
> not supported by the requested resource for the requested method."
>
>
> Never[1] use a bare "try...except". It is the worst thing you can do to a
> Python script, making it almost impossible to debug.
>
> https://realpython.com/blog/python/the-most-diabolical-python-antipattern/
>
> Fix that problem first, get rid of the "try...except" and lying print
> messages, and then either the bug will be obvious, or we can debug further.
>
>
>
>
>
>
> [1] There are exceptions to this rule, for experts. But if you need to ask
> what they are, you're not ready to know

But even the experts will never write such a code - you never know what happens
in a month. Server might throw some new exception, you may move on to
a different project,
etc, etc. ;-)

Thank you.

>
>
> --
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error message

2016-08-04 Thread Steven D'Aprano
On Fri, 5 Aug 2016 01:31 am, GBANE FETIGUE wrote:

> try:
>   parsed_response = json.loads(response)
>   deployid  = parsed_response[u'id']
>   print "Your deployid is: " + deployid
> except:
> print 'Seems the named id  already exists!'


I'm not going to try to debug your code blindfolded with my hands tied
behind my back. Get rid of those "try...except" blocks so that you can see
what error is *actually* happening.

As you have it now, an error happens, somewhere. You don't know where the
error is, or what it is, but Python generates a nice exception showing all
the detail you need to debug.

But you catch that exception, throw it away, and then print a lie.

It is **not true** that the named ID already exists. That is not what the
error is, so why does your script tell a lie?

The output from the server might give you a clue:

"The server refused this request because the request entity is in a format
not supported by the requested resource for the requested method."


Never[1] use a bare "try...except". It is the worst thing you can do to a
Python script, making it almost impossible to debug.

https://realpython.com/blog/python/the-most-diabolical-python-antipattern/

Fix that problem first, get rid of the "try...except" and lying print
messages, and then either the bug will be obvious, or we can debug further.






[1] There are exceptions to this rule, for experts. But if you need to ask
what they are, you're not ready to know.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Python Error message

2016-08-04 Thread Chris Angelico
On Fri, Aug 5, 2016 at 1:31 AM, GBANE FETIGUE  wrote:
> try:
> parsed_response = json.loads(response)
> print "Your applicationId is: " + parsed_response[u'applicationId']
> version_id = parsed_response[u'versionId']
> print "Your versionId is: " + version_id
> except:
> print 'Seems the named application already exists!'
> print 'Seems the named versionId already exists!'
>

This is a very bad idea. You're catching every possible exception and
printing out the same message for all of them. And then continuing
blithely on. Instead, catch ONLY the exceptions you really expect to
be seeing (I'm guessing KeyError here). If anything else goes wrong,
let the exception bubble up.

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


Python Error message

2016-08-04 Thread GBANE FETIGUE
Hi, 
I am running a python script to run some CURL commands, and return the response 
which is the applicationId and the versionId. I was able to do it. Now the 
versionId value supposed to be used on the second CURL as a value of the 
applications key which is an array. but it doesn't work.I 'll post the error 
after running the command as well as the script. It seems like I have an error 
somewhere because the curl works manually if i run. 

ec2-user@ip-172-31-21-77 playbooks]$ python mmc-uploader.py
  % Total% Received % Xferd  Average Speed   TimeTime Time  Current
 Dload  Upload   Total   SpentLeft  Speed
100  23180   119  100  2199496   9173 --:--:-- --:--:-- --:--:--  9200
Your applicationId is: local$fc9277b0-a5b1-4602-8730-714ab7472744
Your versionId is: local$423da1c8-c4e1-47af-9395-57300f839670
  % Total% Received % Xferd  Average Speed   TimeTime Time  Current
 Dload  Upload   Total   SpentLeft  Speed
100  1259  100  1091  100   168   100k  15868 --:--:-- --:--:-- --:--:--  106k
Final responseApache Tomcat/8.0.26 - Error 
reportH1 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
 H2 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
 H3 
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
 BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} 
B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P 
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
 {color : black;}A.name {color : black;}.line {height: 1px; background-color: 
#525D76; border: none;} HTTP Status 415 - type Status reportmessage 
description The server refused this request because the 
request entity is in a format not supported by the reque
 sted resource for the requested method.Apache 
Tomcat/8.0.26
Seems the named id  already exists!

That's the script : 

from subprocess import check_output, STDOUT
import json

response = check_output(["curl", "--basic", "-u", "admin:admin", "-F", 
"file=@/var/lib/jenkins/workspace/Demo-Ci-cd-automation/playbooks/ms3-simple-hello-world-app-1.0.0-SNAPSHOT.zip",
 "-F", "name=ms3-simple-hello-world-app", "-F", "version=1.0.0", "--header", 
"\"Content-Type: multipart/form-data\"", 
"http://52.73.56.141:8080/mmc-console-3.6.2/api/repository";])


try:
parsed_response = json.loads(response)
print "Your applicationId is: " + parsed_response[u'applicationId']
version_id = parsed_response[u'versionId']
print "Your versionId is: " + version_id
except:
print 'Seems the named application already exists!'
print 'Seems the named versionId already exists!'

response = check_output(["curl", "--basic", "-u", "admin:admin", "-d", 
"'{\"name\" : \"ms3-simple-hello-world-app\" , \"servers\": [ 
\"local$d50bdc24-ff04-4327-9284-7bb708e21c25\" ], \"applications\": [ \"" + 
version_id +  "\"]}'", "--header", "\'Content-Type: application/json\'", 
"http://52.73.56.141:8080/mmc-console-3.6.2/api/deployments";])

print 'Final response' + response

try:
  parsed_response = json.loads(response)
  deployid  = parsed_response[u'id']
  print "Your deployid is: " + deployid
except:
print 'Seems the named id  already exists!'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python error

2015-11-03 Thread Terry Reedy

On 11/3/2015 8:07 AM, Ruud van Rooijen wrote:

my code:

from tkinter import *

window = Tk()
label = Label(window, text="miniproject A1")
label.pack()
window.mainloop()


given error:

C:\Users\Ruud\Python35\Scripts\python.exe


Based on the below, python.exe should be in
C:\Users\Ruud\AppData\Local\Programs\Python\Python35-32
_tkinter should then be in
C:\Users\Ruud\AppData\Local\Programs\Python\Python35-32\DLLs

If you moved it, that is your problem.

If you have two python installations, with a second one in
C:\Users\Ruud\Python35, then python.exe should be in that directory, NOT 
scripts.



C:/Users/Ruud/PycharmProjects/School/project.py


I know essentially nothing about PyCharm, even if it is compatible with 
tkinter.



Traceback (most recent call last):

   File "C:/Users/Ruud/PycharmProjects/School/project.py", line 3, in 

 window = Tk()

   File 
"C:\Users\Ruud\AppData\Local\Programs\Python\Python35-32\Lib\tkinter\__init__.py",
line 1867, in __init__

 self.tk = _tkinter.create(screenName, baseName, className,
interactive, wantobjects, useTk, sync, use)

_tkinter.TclError: Can't find a usable init.tcl in the following directories:

 C:/Users/Ruud/AppData/Local/Programs/Python/Python35-32/lib/tcl8.6
C:/Users/Ruud/Python35/lib/tcl8.6 C:/Users/Ruud/lib/tcl8.6
C:/Users/Ruud/Python35/library C:/Users/Ruud/library
C:/Users/Ruud/tcl8.6.4/library C:/Users/tcl8.6.4/library


With a screwed up installation, or pair of installations, it looks 
'everyplace' but the right place.



This probably means that Tcl wasn't installed properly.



i have repaired python several times and i can't find an answer online...
please help


python.exe in scripts is not properly installed.

--
Terry Jan Reedy

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


python error

2015-11-03 Thread Ruud van Rooijen
my code:

from tkinter import *

window = Tk()
label = Label(window, text="miniproject A1")
label.pack()
window.mainloop()


given error:

C:\Users\Ruud\Python35\Scripts\python.exe
C:/Users/Ruud/PycharmProjects/School/project.py

Traceback (most recent call last):

  File "C:/Users/Ruud/PycharmProjects/School/project.py", line 3, in 

window = Tk()

  File 
"C:\Users\Ruud\AppData\Local\Programs\Python\Python35-32\Lib\tkinter\__init__.py",
line 1867, in __init__

self.tk = _tkinter.create(screenName, baseName, className,
interactive, wantobjects, useTk, sync, use)

_tkinter.TclError: Can't find a usable init.tcl in the following directories:

C:/Users/Ruud/AppData/Local/Programs/Python/Python35-32/lib/tcl8.6
C:/Users/Ruud/Python35/lib/tcl8.6 C:/Users/Ruud/lib/tcl8.6
C:/Users/Ruud/Python35/library C:/Users/Ruud/library
C:/Users/Ruud/tcl8.6.4/library C:/Users/tcl8.6.4/library




This probably means that Tcl wasn't installed properly.


i have repaired python several times and i can't find an answer online...
please help


Ruud
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python Error: ImportError: No module named ''folder_name’ at Command Prompt

2015-07-11 Thread Vincent Vande Vyvre

Le 12/07/2015 06:02, Ernest Bonat, Ph.D. a écrit :

Thanks for your help. I had follow the link: How to add a Python module
to syspath?


and I could not make it work. I did use sys.path.insert() and
sys.path.append() as:

Examples: sys.path.append('/python_mvc_calculator/calculator/') or
sys.path.insert(0, "/python_mvc_calculator/calculator")

I did try it to:
sys.path.append('/python_mvc_calculator/calculator/controller') or
sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too!

The main.py file is in python_mvc_calculator/calculator folder and I
need to import a module calculatorcontroller.py in
"python_mvc_calculator/calculator/controller"

I hope this explanation helps a bit!



Thanks



If "/python_mvc_calculator/calculator/controller" is a folder and if you 
have a file __init__.py into this folder, you have to use:


sys.path.insert(0, "/python_mvc_calculator/calculator/controller")
from calculatorcontroller import foo # or import calculatorcontroller

But the init file must be named __init__.py NOT init.py as sayed in 
askubuntu.


Vincent

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


Fwd: Python Error: ImportError: No module named ''folder_name’ at Command Prompt

2015-07-11 Thread Ernest Bonat, Ph.D.
Thanks for your help. I had follow the link: How to add a Python module
to syspath?

<http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath
>
and I could not make it work. I did use sys.path.insert() and
sys.path.append() as:

Examples: sys.path.append('/python_mvc_calculator/calculator/') or
sys.path.insert(0, "/python_mvc_calculator/calculator")

I did try it to:
sys.path.append('/python_mvc_calculator/calculator/controller') or
sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too!

The main.py file is in python_mvc_calculator/calculator folder and I
need to import a module calculatorcontroller.py in
"python_mvc_calculator/calculator/controller"

I hope this explanation helps a bit!

<http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath
>

Thanks

Ernest Bonat, Ph.D.
Senior Software Engineer | Senior Data Analyst
Visual WWW, Inc. | President and CEO
115 NE 39th Avenue | Hillsboro, OR 97124
Cell: 503.730.4556 | Email: ernest.bo...@gmail.com
<mailto:ernest.bo...@gmail.com>

/The content of this email is confidential. It is intended only for the
use of the persons named above. If you are not the intended recipient,
you are hereby notified that any review, dissemination, distribution or
duplication of this communication is strictly prohibited. If you are not
the intended recipient, please contact the sender by reply email and
destroy all copies of the original message./
-- Forwarded message --
From: Terry Reedy 
Date: Sat, Jul 11, 2015 at 8:59 PM
Subject: Re: Python Error: ImportError: No module named ''folder_name’ at
Command Prompt
To: "Ernest Bonat, Ph.D." 


Please send this followup to python-list.

On 7/11/2015 11:26 PM, Ernest Bonat, Ph.D. wrote:

> Hey Terry,
>
> Thanks for your help. I had follow the link: How to add a Python module
> to syspath?
> <
> http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath
> >
> and I could not make it work. I did use sys.path.insert() and
> sys.path.append() as:
>
> Examples: sys.path.append('/python_mvc_calculator/calculator/') or
> sys.path.insert(0, "/python_mvc_calculator/calculator")
>
> I did try it to:
> sys.path.append('/python_mvc_calculator/calculator/controller') or
> sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too!
>
> The main.py file is in python_mvc_calculator/calculator folder and I
> need to import a module calculatorcontroller.py in
> "python_mvc_calculator/calculator/controller"
>
> I hope this explanation helps a bit!
>
> <
> http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath
> >
>
> Thanks
>
> Ernest Bonat, Ph.D.
> Senior Software Engineer | Senior Data Analyst
> Visual WWW, Inc. | President and CEO
> 115 NE 39th Avenue | Hillsboro, OR 97124
> Cell: 503.730.4556 | Email: ernest.bo...@gmail.com
> <mailto:ernest.bo...@gmail.com>
>
> /The content of this email is confidential. It is intended only for the
> use of the persons named above. If you are not the intended recipient,
> you are hereby notified that any review, dissemination, distribution or
> duplication of this communication is strictly prohibited. If you are not
> the intended recipient, please contact the sender by reply email and
> destroy all copies of the original message./
>
> On Sat, Jul 11, 2015 at 5:02 PM, Terry Reedy  <mailto:tjre...@udel.edu>> wrote:
>
> On 7/11/2015 11:15 AM, Ernest Bonat, Ph.D. wrote:
>
> Hi All,
>
>
> I’m doing a CSV data analysis in Python using Eclipse IDE/PyDev.
> I have
> organized my project using the standard MVC architecture. In
> Eclipse IDE
> everything is working properly. When I run my main.py file it at
> Command
> Prompt I got an error: ImportError: No module named
> 'folder_name'. It’s
> like the location path of the ‘'folder_name’ was not found. Do I
> need to
> update my main.py file to run it at the Command Prompt?
>
>
> 'import module' searches directories on sys.path for a file or
> directory named 'module'.  sys.path starts with '.', which
> represents the 'current' directory. If you start with the directory
> containing main.py as current directory and 'folder-name' is in the
> same directory, the import should work.  Otherwise ??? EclipseIDE
> probably modifies the current dir and/or path to make things work.
>
> For any more help, post the OS and locations of main.py,
> folder_name, and python.
>
> --
> Terry Jan Reedy
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: Python Error: ImportError: No module named ''folder_name’ at Command Prompt

2015-07-11 Thread Ernest Bonat, Ph.D.
Thanks

Ernest Bonat, Ph.D.
Senior Software Engineer | Senior Data Analyst
Visual WWW, Inc. | President and CEO
115 NE 39th Avenue | Hillsboro, OR 97124
Cell: 503.730.4556 | Email: ernest.bo...@gmail.com

*The content of this email is confidential. It is intended only for the use
of the persons named above. If you are not the intended recipient, you are
hereby notified that any review, dissemination, distribution or duplication
of this communication is strictly prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.*

-- Forwarded message --
From: Terry Reedy 
Date: Sat, Jul 11, 2015 at 8:59 PM
Subject: Re: Python Error: ImportError: No module named ''folder_name’ at
Command Prompt
To: "Ernest Bonat, Ph.D." 


Please send this followup to python-list.

On 7/11/2015 11:26 PM, Ernest Bonat, Ph.D. wrote:

> Hey Terry,
>
> Thanks for your help. I had follow the link: How to add a Python module
> to syspath?
> <
> http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath
> >
> and I could not make it work. I did use sys.path.insert() and
> sys.path.append() as:
>
> Examples: sys.path.append('/python_mvc_calculator/calculator/') or
> sys.path.insert(0, "/python_mvc_calculator/calculator")
>
> I did try it to:
> sys.path.append('/python_mvc_calculator/calculator/controller') or
> sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too!
>
> The main.py file is in python_mvc_calculator/calculator folder and I
> need to import a module calculatorcontroller.py in
> "python_mvc_calculator/calculator/controller"
>
> I hope this explanation helps a bit!
>
> <
> http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath
> >
>
> Thanks
>
> Ernest Bonat, Ph.D.
> Senior Software Engineer | Senior Data Analyst
> Visual WWW, Inc. | President and CEO
> 115 NE 39th Avenue | Hillsboro, OR 97124
> Cell: 503.730.4556 | Email: ernest.bo...@gmail.com
> <mailto:ernest.bo...@gmail.com>
>
> /The content of this email is confidential. It is intended only for the
> use of the persons named above. If you are not the intended recipient,
> you are hereby notified that any review, dissemination, distribution or
> duplication of this communication is strictly prohibited. If you are not
> the intended recipient, please contact the sender by reply email and
> destroy all copies of the original message./
>
> On Sat, Jul 11, 2015 at 5:02 PM, Terry Reedy  <mailto:tjre...@udel.edu>> wrote:
>
> On 7/11/2015 11:15 AM, Ernest Bonat, Ph.D. wrote:
>
> Hi All,
>
>
> I’m doing a CSV data analysis in Python using Eclipse IDE/PyDev.
> I have
> organized my project using the standard MVC architecture. In
> Eclipse IDE
> everything is working properly. When I run my main.py file it at
> Command
> Prompt I got an error: ImportError: No module named
> 'folder_name'. It’s
> like the location path of the ‘'folder_name’ was not found. Do I
> need to
> update my main.py file to run it at the Command Prompt?
>
>
> 'import module' searches directories on sys.path for a file or
> directory named 'module'.  sys.path starts with '.', which
> represents the 'current' directory. If you start with the directory
> containing main.py as current directory and 'folder-name' is in the
> same directory, the import should work.  Otherwise ??? EclipseIDE
> probably modifies the current dir and/or path to make things work.
>
> For any more help, post the OS and locations of main.py,
> folder_name, and python.
>
> --
> Terry Jan Reedy
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Error: ImportError: No module named ''folder_name’ at Command Prompt

2015-07-11 Thread Terry Reedy

On 7/11/2015 11:15 AM, Ernest Bonat, Ph.D. wrote:

Hi All,


I’m doing a CSV data analysis in Python using Eclipse IDE/PyDev. I have
organized my project using the standard MVC architecture. In Eclipse IDE
everything is working properly. When I run my main.py file it at Command
Prompt I got an error: ImportError: No module named 'folder_name'. It’s
like the location path of the ‘'folder_name’ was not found. Do I need to
update my main.py file to run it at the Command Prompt?


'import module' searches directories on sys.path for a file or directory 
named 'module'.  sys.path starts with '.', which represents the 
'current' directory. If you start with the directory containing main.py 
as current directory and 'folder-name' is in the same directory, the 
import should work.  Otherwise ??? EclipseIDE probably modifies the 
current dir and/or path to make things work.


For any more help, post the OS and locations of main.py, folder_name, 
and python.


--
Terry Jan Reedy


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


Python Error: ImportError: No module named ''folder_name’ at Command Prompt

2015-07-11 Thread Ernest Bonat, Ph.D.
Hi All,


I’m doing a CSV data analysis in Python using Eclipse IDE/PyDev. I have
organized my project using the standard MVC architecture. In Eclipse IDE
everything is working properly. When I run my main.py file it at Command
Prompt I got an error: ImportError: No module named 'folder_name'. It’s
like the location path of the ‘'folder_name’ was not found. Do I need to
update my main.py file to run it at the Command Prompt?


Thank you for all your help,


Thanks

Ernest Bonat, Ph.D.
Senior Software Engineer | Senior Data Analyst
Visual WWW, Inc. | President and CEO
115 NE 39th Avenue | Hillsboro, OR 97124
Cell: 503.730.4556 | Email: ernest.bo...@gmail.com

*The content of this email is confidential. It is intended only for the use
of the persons named above. If you are not the intended recipient, you are
hereby notified that any review, dissemination, distribution or duplication
of this communication is strictly prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.*
-- 
https://mail.python.org/mailman/listinfo/python-list


cx_Freeze:Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'

2015-02-02 Thread iMath
I downloaded cx_Freeze from here, installed it successfully on Ubuntu following 
this thread .

After run python3 setup.py build in cx_Freeze/samples/simple,then change the 
dir to cx_Freeze/samples/simple/build/exe.linux-i686-3.4,run the following 
command ,I got the error

?7?4  exe.linux-i686-3.4  ./hello

Fatal Python error: Py_Initialize: Unable to get the locale encoding

ImportError: No module named 'encodings'

[1]3950 abort  ./hello

?7?4  exe.linux-i686-3.4  

any idea on fixing this issue ?-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error: PyCOND_WAIT(gil_cond) failed

2014-12-12 Thread dieter
keepplearningpython  writes:

> I am running ipython3 on Unix and constantly see this crash -
> It happens when i try to issue commands on the ipython interactive shell.
>
> I have tried to set the PYTHONDIR to /var/tmp/ in case there was an issue 
> accessing the default location of the history file. However, this makes no 
> difference.
>
> I can run a command a few times successfully after which I hit this error.
> ...
> Any suggestions on what might be going on?
>
>
>
>
> Fatal Python error: PyCOND_WAIT(gil_cond) failed

Apparently, some thread should wait for the GIL
(Python's Global Interpreter Lock) but instead of waiting,
the operation results in an error.

This looks like an important bug in GIL handling -- likely
caused by some C extension, likely executing Python code
without first acquiring the GIL.

It might be difficult to locate the error: likely C level
debugging will be necessary. Should my hypothesis be true,
a change in C code would be necessary to fix the problem.


I recommend to check for known problems related to GIL handling
for all C implemented components of your application.
If you are lucky, your problem is known and has been fixed
in a different version. Then upgrading would be all you need to do.

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


Fatal Python error: PyCOND_WAIT(gil_cond) failed

2014-12-11 Thread keepplearningpython
Hi,
I am running ipython3 on Unix and constantly see this crash -
It happens when i try to issue commands on the ipython interactive shell.

I have tried to set the PYTHONDIR to /var/tmp/ in case there was an issue 
accessing the default location of the history file. However, this makes no 
difference.

I can run a command a few times successfully after which I hit this error.

This is my python version info 


Python 3.3.2 (default, Nov 14 2014, 12:28:17)
Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help  -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.


Any suggestions on what might be going on?




Fatal Python error: PyCOND_WAIT(gil_cond) failed

Thread 0x088e8900:
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/history.py", line 664 
in _writeout_input_cache
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/history.py", line 680 
in writeout_cache
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/history.py", line 65 
in needs_sqlite
  File "", line 2 in writeout_cache
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/history.py", line 733 
in run
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/history.py", line 65 
in needs_sqlite
  File "", line 2 in run
  File "/opt/jde/lib/python3.3/threading.py", line 637 in _bootstrap_inner
  File "/opt/jde/lib/python3.3/threading.py", line 614 in _bootstrap

Current thread 0x0804b000:
  File "/opt/jde/lib/python3.3/logging/__init__.py", line 940 in emit
  File "/opt/jde/lib/python3.3/logging/__init__.py", line 833 in handle
  File "/opt/jde/lib/python3.3/logging/__init__.py", line 1439 in callHandlers
  File "/opt/jde/lib/python3.3/logging/__init__.py", line 1377 in handle
  File "/opt/jde/lib/python3.3/logging/__init__.py", line 1367 in _log
  File "/opt/jde/lib/python3.3/logging/__init__.py", line 1232 in info
  File "/var/root/diags/src/lib/python/jde/jde/Model.py", line 644 in show
  File "", line 1 in 
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/interactiveshell.py", 
line 2828 in run_code
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/interactiveshell.py", 
line 2778 in run_ast_nodes
  File "/opt/jde/lib/python3.3/site-packages/IPython/core/interactiveshell.py", 
line 2668 in run_cell
  File 
"/opt/jde/lib/python3.3/site-packages/IPython/terminal/interactiveshell.py", 
line 555 in interact
  File 
"/opt/jde/lib/python3.3/site-packages/IPython/terminal/interactiveshell.py", 
line 436 in mainloop
  File "/opt/jde/lib/python3.3/site-packages/IPython/terminal/ipapp.py", line 
362 in start
  File "/opt/jde/lib/python3.3/site-packages/IPython/config/application.py", 
line 545 in launch_instance
  File "/opt/jde/lib/python3.3/site-packages/IPython/__init__.py", line 118 in 
start_ipython
  File "/opt/jde/bin/ipython3", line 6 in 
Abort (core dumped)

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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-17 Thread alex23
On Jun 16, 2:09 pm, Larry Hudson  wrote:
> On 06/15/2013 03:10 PM, alex23 wrote:
> > (Sorry for the ugly url, it's a Google translation of a french
> > language page)
>
> Somewhat OT, but have you ever looked at tinyurl.com?  Very useful for this 
> sort of thing.

>From past comments on this list, people can be reticent to click on
URL shortener links as it's not immediately obvious where it will take
them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread Larry Hudson

On 06/15/2013 03:10 PM, alex23 wrote:

On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote:




Here's a report of a similar issue with Blender (which also provides a
local install of Python under Windows):
http://translate.google.com.au/translate?hl=en&sl=fr&u=http://blenderclan.tuxfamily.org/html/modules/newbb/viewtopic.php%3Ftopic_id%3D36497&prev=/search%3Fq%3Dinkscape%2BCodecRegistryError

(Sorry for the ugly url, it's a Google translation of a french
language page)


Somewhat OT, but have you ever looked at tinyurl.com?  Very useful for this 
sort of thing.

 -=- Larry -=-

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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread Terry Reedy

On 6/15/2013 8:03 PM, MRAB wrote:

On 15/06/2013 23:10, alex23 wrote:

\__init__.py", line 123

raise CodecRegistryError,\
^
SyntaxError: invalid syntax



To me that traceback looks like it's Python 3 trying to run code written
for Python 2.


If that is the case, the ^ should be under the ',' (and perhaps it once 
was ;-). If really at the beginning of the line, then the error must be 
on the previous line. Even then, the examples I have tried point to the 
'e' or 'raise'. Take a look in the file.


--
Terry Jan Reedy

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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread Dave Angel

On 06/15/2013 10:44 PM, lucabrasi wrote:

On Saturday, June 15, 2013 5:03:27 PM UTC-7, MRAB wrote:

On 15/06/2013 23:10, alex23 wrote:




   should be banned>



Do you have a separate installation of Python? It's possible it may be



conflicting. If you rename it's folder to something else (which will



temporarily break that install), do you still see this same issue in



Inkscape?








Your message was a hard-to-read doble-spaced copy of someone else's 
comments.  If you have nothing to add, why bother posting?  Especially 
with googlegroups.


If you do have something to say, make sure it follows the part you're 
quoting, and that it does not begin with those bracket separators. 
Otherwise it simply lies buried in the context, and your contribution or 
question is lost.


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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread lucabrasi
On Saturday, June 15, 2013 7:44:09 PM UTC-7, lucabrasi wrote:
> On Saturday, June 15, 2013 5:03:27 PM UTC-7, MRAB wrote:
> 
> > On 15/06/2013 23:10, alex23 wrote:
> 
> > 
> 
> > > On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote:
> 
> > 
> 
> > >> I get this error when I try to save .dxf files in Inkscape:
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> Fatal Python error: Py_Initialize: can't initialize sys standard streams
> 
> > 
> 
> > >>
> 
> > 
> 
> > >> Then it seems to recover but it doesn't really recover. It saves the 
> > >> files and then DraftSite won't open them. Here is what the  > thing says 
> > >> when Inkscape tried to fix the saving problem.
> 
> > 
> 
> > >
> 
> > 
> 
> > > What do you mean by "Inkscape tried to fix the saving problem"?
> 
> > 
> 
> > >
> 
> > 
> 
> > >> File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", 
> > >> line 123
> 
> > 
> 
> > >> raise CodecRegistryError,\
> 
> > 
> 
> > >> ^
> 
> > 
> 
> > >> SyntaxError: invalid syntax
> 
> > 
> 
> > >
> 
> > 
> 
> > To me that traceback looks like it's Python 3 trying to run code written 
> 
> > 
> 
> > for Python 2.
> 
> > 
> 
> > 
> 
> > 
> 
> > > Here's a report of a similar issue with Blender (which also provides a
> 
> > 
> 
> > > local install of Python under Windows):
> 
> > 
> 
> > > http://translate.google.com.au/translate?hl=en&sl=fr&u=http://blenderclan.tuxfamily.org/html/modules/newbb/viewtopic.php%3Ftopic_id%3D36497&prev=/search%3Fq%3Dinkscape%2BCodecRegistryError
> 
> > 
> 
> > >
> 
> > 
> 
> > > (Sorry for the ugly url, it's a Google translation of a french
> 
> > 
> 
> > > language page)
> 
> > 
> 
> > >
> 
> > 
> 
> > > Do you have a separate installation of Python? It's possible it may be
> 
> > 
> 
> > > conflicting. If you rename it's folder to something else (which will
> 
> > 
> 
> > > temporarily break that install), do you still see this same issue in
> 
> > 
> 
> > > Inkscape?
> 
> > 
> 
> > >

Got the problem fixed. I noticed the conflict between 2.X and 3.3 on the French 
board.  I just uninstalled and otherwise deleted all python files and 
reinstalled with only 3.3.  Works like a charm.
Thanks to everyone. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread lucabrasi
On Saturday, June 15, 2013 5:03:27 PM UTC-7, MRAB wrote:
> On 15/06/2013 23:10, alex23 wrote:
> 
> > On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote:
> 
> >> I get this error when I try to save .dxf files in Inkscape:
> 
> >>
> 
> >> Fatal Python error: Py_Initialize: can't initialize sys standard streams
> 
> >>
> 
> >> Then it seems to recover but it doesn't really recover. It saves the files 
> >> and then DraftSite won't open them. Here is what the  > thing says when 
> >> Inkscape tried to fix the saving problem.
> 
> >
> 
> > What do you mean by "Inkscape tried to fix the saving problem"?
> 
> >
> 
> >> File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", 
> >> line 123
> 
> >> raise CodecRegistryError,\
> 
> >> ^
> 
> >> SyntaxError: invalid syntax
> 
> >
> 
> To me that traceback looks like it's Python 3 trying to run code written 
> 
> for Python 2.
> 
> 
> 
> > Here's a report of a similar issue with Blender (which also provides a
> 
> > local install of Python under Windows):
> 
> > http://translate.google.com.au/translate?hl=en&sl=fr&u=http://blenderclan.tuxfamily.org/html/modules/newbb/viewtopic.php%3Ftopic_id%3D36497&prev=/search%3Fq%3Dinkscape%2BCodecRegistryError
> 
> >
> 
> > (Sorry for the ugly url, it's a Google translation of a french
> 
> > language page)
> 
> >
> 
> > Do you have a separate installation of Python? It's possible it may be
> 
> > conflicting. If you rename it's folder to something else (which will
> 
> > temporarily break that install), do you still see this same issue in
> 
> > Inkscape?
> 
> >

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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread MRAB

On 15/06/2013 23:10, alex23 wrote:

On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote:

I get this error when I try to save .dxf files in Inkscape:

Fatal Python error: Py_Initialize: can't initialize sys standard streams

Then it seems to recover but it doesn't really recover. It saves the files and 
then DraftSite won't open them. Here is what the  > thing says when Inkscape 
tried to fix the saving problem.


What do you mean by "Inkscape tried to fix the saving problem"?


File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", line 
123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax


To me that traceback looks like it's Python 3 trying to run code written 
for Python 2.



Here's a report of a similar issue with Blender (which also provides a
local install of Python under Windows):
http://translate.google.com.au/translate?hl=en&sl=fr&u=http://blenderclan.tuxfamily.org/html/modules/newbb/viewtopic.php%3Ftopic_id%3D36497&prev=/search%3Fq%3Dinkscape%2BCodecRegistryError

(Sorry for the ugly url, it's a Google translation of a french
language page)

Do you have a separate installation of Python? It's possible it may be
conflicting. If you rename it's folder to something else (which will
temporarily break that install), do you still see this same issue in
Inkscape?



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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread lucabrasi
On Saturday, June 15, 2013 3:10:07 PM UTC-7, alex23 wrote:
> On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote:
> 
> > I get this error when I try to save .dxf files in Inkscape:
> 
> >
> 
> > Fatal Python error: Py_Initialize: can't initialize sys standard streams
> 
> >
> 
> > Then it seems to recover but it doesn't really recover. It saves the files 
> > and then DraftSite won't open them. Here is what the  > thing says when 
> > Inkscape tried to fix the saving problem.
> 
> 
> 
> What do you mean by "Inkscape tried to fix the saving problem"?
> 
> 
> 
> > File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", 
> > line 123
> 
> > raise CodecRegistryError,\
> 
> > ^
> 
> > SyntaxError: invalid syntax
> 
> 
> 
> Here's a report of a similar issue with Blender (which also provides a
> 
> local install of Python under Windows):
> 
> http://translate.google.com.au/translate?hl=en&sl=fr&u=http://blenderclan.tuxfamily.org/html/modules/newbb/viewtopic.php%3Ftopic_id%3D36497&prev=/search%3Fq%3Dinkscape%2BCodecRegistryError
> 
> 
> 
> (Sorry for the ugly url, it's a Google translation of a french
> 
> language page)
> 
> 
> 
> Do you have a separate installation of Python? It's possible it may be
> 
> conflicting. If you rename it's folder to something else (which will
> 
> temporarily break that install), do you still see this same issue in
> 
> Inkscape?

Inkscape told me to not worry about the problem.  That somehow it had made a 
mistake and then it showed a little window with this information.
> File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", line 
> 123
> raise CodecRegistryError,\
> ^
> SyntaxError: invalid syntax 

I said Inkscape but maybe it is system message and not from Inkscape.
I will try your suggestions now, and thanks to everyone for responding so 
quickly.

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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread alex23
On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote:
> I get this error when I try to save .dxf files in Inkscape:
>
> Fatal Python error: Py_Initialize: can't initialize sys standard streams
>
> Then it seems to recover but it doesn't really recover. It saves the files 
> and then DraftSite won't open them. Here is what the  > thing says when 
> Inkscape tried to fix the saving problem.

What do you mean by "Inkscape tried to fix the saving problem"?

> File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", line 
> 123
> raise CodecRegistryError,\
> ^
> SyntaxError: invalid syntax

Here's a report of a similar issue with Blender (which also provides a
local install of Python under Windows):
http://translate.google.com.au/translate?hl=en&sl=fr&u=http://blenderclan.tuxfamily.org/html/modules/newbb/viewtopic.php%3Ftopic_id%3D36497&prev=/search%3Fq%3Dinkscape%2BCodecRegistryError

(Sorry for the ugly url, it's a Google translation of a french
language page)

Do you have a separate installation of Python? It's possible it may be
conflicting. If you rename it's folder to something else (which will
temporarily break that install), do you still see this same issue in
Inkscape?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread alex23
On Jun 16, 7:43 am, Mark Lawrence  wrote:
> Your Python version would help :)  How did you install Inkscape?  It
> looks strange to see it in Program Files, I'd normally expect to see it
> in the site packages directory.

Inkscape is an application, not a library. It provides its own local
install of Python to allow for user extensions.


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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread Mark Lawrence

On 15/06/2013 22:29, lucabrasi...@gmail.com wrote:

I get this error when I try to save .dxf files in Inkscape:

Fatal Python error: Py_Initialize: can't initialize sys standard streams

Then it seems to recover but it doesn't really recover. It saves the files and 
then DraftSite won't open them. Here is what the thing says when Inkscape tried 
to fix the saving problem.

File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", line 
123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax

Here are my computer specs if you need them:

Tech Support Guy System Info Utility version 1.0.0.2
OS Version: Microsoft Windows 7 Ultimate, Service Pack 1, 64 bit
Processor: AMD FX(tm)-6100 Six-Core Processor, AMD64 Family 21 Model 1 Stepping 
2
Processor Count: 6
RAM: 16330 Mb
Graphics Card: NVIDIA GeForce GTX 560, 1024 Mb
Hard Drives: C: Total - 239806 MB, Free - 39808 MB; D: Total - 61553 MB, Free - 
46085 MB; F: Total - 1907726 MB, Free - 1461558 MB;
Motherboard: ASUSTeK COMPUTER INC., M5A97
Antivirus: avast! Internet Security, Updated and Enabled

Any help would be appreciated. I posted on another forum 
http://forums.techguy.org  but no one answered, as of yet anyway.  It is kind 
of weird because they answer everything. So I am assuming only Python users 
might know.

Thank you for considering my problem.



Your Python version would help :)  How did you install Inkscape?  It 
looks strange to see it in Program Files, I'd normally expect to see it 
in the site packages directory.


--
"Steve is going for the pink ball - and for those of you who are 
watching in black and white, the pink is next to the green." Snooker 
commentator 'Whispering' Ted Lowe.


Mark Lawrence

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


Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread lucabrasi154
I get this error when I try to save .dxf files in Inkscape:

Fatal Python error: Py_Initialize: can't initialize sys standard streams

Then it seems to recover but it doesn't really recover. It saves the files and 
then DraftSite won't open them. Here is what the thing says when Inkscape tried 
to fix the saving problem.

File "D:\Program Files (x86)\Inkscape\python\Lib\encodings\__init__.py", line 
123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax

Here are my computer specs if you need them:

Tech Support Guy System Info Utility version 1.0.0.2
OS Version: Microsoft Windows 7 Ultimate, Service Pack 1, 64 bit
Processor: AMD FX(tm)-6100 Six-Core Processor, AMD64 Family 21 Model 1 Stepping 
2
Processor Count: 6
RAM: 16330 Mb
Graphics Card: NVIDIA GeForce GTX 560, 1024 Mb
Hard Drives: C: Total - 239806 MB, Free - 39808 MB; D: Total - 61553 MB, Free - 
46085 MB; F: Total - 1907726 MB, Free - 1461558 MB;
Motherboard: ASUSTeK COMPUTER INC., M5A97
Antivirus: avast! Internet Security, Updated and Enabled

Any help would be appreciated. I posted on another forum 
http://forums.techguy.org  but no one answered, as of yet anyway.  It is kind 
of weird because they answer everything. So I am assuming only Python users 
might know.

Thank you for considering my problem.

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


Re: Fatal Python error

2013-05-31 Thread nn
On May 29, 10:05 am, Joshua Landau  wrote:
> On 29 May 2013 14:02, Dave Angel  wrote:
>
> > On 05/29/2013 08:45 AM, Oscar Benjamin wrote:
> > Joshua:  Avoid doing anything complex inside an exception handler.
>
> Unfortunately, Ranger (the file manager in question) wraps a lot of stuff
> in one big exception handler. Hence there isn't much choice. The original
> wasn't actually in an infinite recursion, too, but just a recursion over a
> large directory.
>
> Is there a reason that Python 3 can't be made to work like Python 2 and
> PyPy, and -if not- should it? The catchable fail would be much nicer than
> just bombing the program.
>
> In the meantime the algorithm should just be reworked, but it seems like a
> larger step than should be needed.
>
> If nothing else, the exception frame is huge.  I probably would have
>
> > spotted it except for the indentation problem triggered by html.  The top
> > level code following your function didn't have any loops, so it wasn't a
> > problem.
>
> > Can anyone help Joshua put his gmail into text mode?
>
> I've found a new option. As a test, here's a simplified version without the
> property:
>
> def loop():
>     try:
>         (lambda: None)()
>     except:
>         pass
>
>     loop()
>
> try:
>     loop()
> except RuntimeError:
>     pass
>
> which is pretty much Oscar Benjamin's, but less stupid.

If nobody else has, I would recommend you submit a bug at
bugs.python.org.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2013-05-29 Thread Oscar Benjamin
On 29 May 2013 14:02, Dave Angel  wrote:
> On 05/29/2013 08:45 AM, Oscar Benjamin wrote:
>
> More likely a bug in the 2.x interpreter.  Once inside an exception handler,
> that frame must be held somehow.  If not on the stack, then in some separate
> list.  So the logic will presumably fill memory, it just may take longer on
> 2.x .

I'm not so sure. The following gives the same behaviour in 2.7, 3.2 and 3.3:

$ cat tmp.py
def loop():
loop()

loop()

$ py -3.2 tmp.py
Traceback (most recent call last):
  File "tmp.py", line 4, in 
loop()
  File "tmp.py", line 2, in loop
loop()
  File "tmp.py", line 2, in loop
loop()
  File "tmp.py", line 2, in loop
loop()
  File "tmp.py", line 2, in loop
...

However the following leads to a RuntimeError in 2.7 but different
stack overflow errors in 3.2 and 3.3:

$ cat tmp.py
def loop():
try:
(lambda: None)()
except RuntimeError:
pass
loop()

loop()

$ py -2.7 tmp.py
Traceback (most recent call last):
  File "tmp.py", line 8, in 
loop()
  File "tmp.py", line 6, in loop
loop()
  File "tmp.py", line 6, in loop
loop()
  File "tmp.py", line 6, in loop
loop()
  File "tmp.py", line 6, in loop
...
RuntimeError: maximum recursion depth exceeded

$ py -3.2 tmp.py
Fatal Python error: Cannot recover from stack overflow.

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

$ py -3.3 tmp.py
Fatal Python error: Cannot recover from stack overflow.

Current thread 0x05c4:
  File "tmp.py", line 3 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
  File "tmp.py", line 6 in loop
...

I would expect this to give "RuntimeError: maximum recursion depth
exceeded" in all three cases.


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


Re: Fatal Python error

2013-05-29 Thread rusi
On May 29, 5:43 pm, Joshua Landau  wrote:
> On 29 May 2013 13:25, Dave Angel  wrote:
>
> > On 05/29/2013 07:48 AM, Joshua Landau wrote:
>
> >> Hello all, again. Instead of revising like I'm meant to be, I've been
> >> delving into a bit of Python and I've come up with this code:
>
> > To start with, please post in text mode.  By using html, you've completely
> > messed up any indentation you presumably had.
>
> Appologies, I use GMail and I don't know how to force text-only

In gmail
New interface:
There should be a down arrow next to the trash-can right bottom of
posting-screen
Click the down-arrow. YOu should see a 'choose text-only' option

Old interface:
When posting a new message, right at the top next to all the
formatting icons is a text-only link
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 14:02, Dave Angel  wrote:

> On 05/29/2013 08:45 AM, Oscar Benjamin wrote:
> Joshua:  Avoid doing anything complex inside an exception handler.


Unfortunately, Ranger (the file manager in question) wraps a lot of stuff
in one big exception handler. Hence there isn't much choice. The original
wasn't actually in an infinite recursion, too, but just a recursion over a
large directory.

Is there a reason that Python 3 can't be made to work like Python 2 and
PyPy, and -if not- should it? The catchable fail would be much nicer than
just bombing the program.

In the meantime the algorithm should just be reworked, but it seems like a
larger step than should be needed.

If nothing else, the exception frame is huge.  I probably would have
> spotted it except for the indentation problem triggered by html.  The top
> level code following your function didn't have any loops, so it wasn't a
> problem.
>
> Can anyone help Joshua put his gmail into text mode?


I've found a new option. As a test, here's a simplified version without the
property:

def loop():
try:
(lambda: None)()
except:
pass

loop()

try:
loop()
except RuntimeError:
pass

which is pretty much Oscar Benjamin's, but less stupid.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2013-05-29 Thread Marcel Rodrigues
I think the issue here has little to do with classes/objects/properties.
See, for example, the code posted by Oscar Benjamin.

What that code is trying to do is similar to responding to an "Out Of
Memory" error with something that might require more memory allocation.

Even if we consider the Py3 behavior here a bug, that code is unreliable by
design. It's an infinite loop at the best.


2013/5/29 Joshua Landau 

> On 29 May 2013 13:30, Marcel Rodrigues  wrote:
> >
> > I just tried your code with similar results: it does nothing on PyPy
> 2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump.
> > It's a little weird but so is the code. You have defined a function that
> calls itself unconditionally. This will cause a stack overflow, which is a
> RuntimeError.
>
>
> The weirdness of the code is simply as I've taken all the logic and
> conditionality away, since it was irrelevant. Why, though, does removing
> any one element make it fail properly? That's what's confusing, largely.
>
>
> >
> >  Since you are handling this very exception with a pass statement, we
> would expect that no error occurs. But the fatal error message seems pretty
> informative at this point: "Cannot recover from stack overflow.".
> >
> > One thing to note is that while it's reasonable to handle exceptions
> that happens at the level of your Python code, like a ValueError, it's not
> so reasonable to try to handle something that may disturb the interpreter
> itself in a lower level, like a stack overflow (I think that the stack used
> by your code is the same stack used by the interpreter code, but I'm not
> sure).
>
>
> What is the expected response here then? Should I ever feel justified in
> catching a Stack Overflow error? This code was extracted from a file
> manager after much difficulty, but it should have been "caught" by a global
> try...except and not crashed the whole program immediately. I'd imagine
> that's a good enough reason to bring this up.
>
>
>
> Also;
> This works for the code:
>
> def loop():
> thingwithproperty.prop
> loop()
>
> This does not:
>
> def loop():
> try:
> thingwithproperty.prop
> except:
> pass
> loop()
>
> thingwithproperty.prop NEVER creates an error.
> (.prop is the new .property)
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 13:30, Marcel Rodrigues  wrote:
>
> I just tried your code with similar results: it does nothing on PyPy
2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump.
> It's a little weird but so is the code. You have defined a function that
calls itself unconditionally. This will cause a stack overflow, which is a
RuntimeError.


The weirdness of the code is simply as I've taken all the logic and
conditionality away, since it was irrelevant. Why, though, does removing
any one element make it fail properly? That's what's confusing, largely.

>
>  Since you are handling this very exception with a pass statement, we
would expect that no error occurs. But the fatal error message seems pretty
informative at this point: "Cannot recover from stack overflow.".
>
> One thing to note is that while it's reasonable to handle exceptions that
happens at the level of your Python code, like a ValueError, it's not so
reasonable to try to handle something that may disturb the interpreter
itself in a lower level, like a stack overflow (I think that the stack used
by your code is the same stack used by the interpreter code, but I'm not
sure).


What is the expected response here then? Should I ever feel justified in
catching a Stack Overflow error? This code was extracted from a file
manager after much difficulty, but it should have been "caught" by a global
try...except and not crashed the whole program immediately. I'd imagine
that's a good enough reason to bring this up.



Also;
This works for the code:

def loop():
thingwithproperty.prop
loop()

This does not:

def loop():
try:
thingwithproperty.prop
except:
pass
loop()

thingwithproperty.prop NEVER creates an error.
(.prop is the new .property)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2013-05-29 Thread Dave Angel

On 05/29/2013 08:45 AM, Oscar Benjamin wrote:

On 29 May 2013 12:48, Joshua Landau  wrote:

Hello all, again. Instead of revising like I'm meant to be, I've been
delving into a bit of Python and I've come up with this code:


Here's a simpler example that gives similar results:

$ py -3.3
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

def broken():

...   try:
... broken()
...   except RuntimeError:
... broken()
...

broken()

Fatal Python error: Cannot recover from stack overflow.

Current thread 0x058c:
   File "", line 3 in broken
   File "", line 3 in broken
...

Under Python 2.7.5 it just goes into an infinite loop. Under Python
3.2.5 and 3.3.2 it crashes the interpreter as shown above.

What the broken() function is doing is totally stupid: responding to a
recursion error with more recursion. However this may indicate or be
considered a bug in the 3.x interpreter.


Oscar



More likely a bug in the 2.x interpreter.  Once inside an exception 
handler, that frame must be held somehow.  If not on the stack, then in 
some separate list.  So the logic will presumably fill memory, it just 
may take longer on 2.x .


Joshua:  Avoid doing anything complex inside an exception handler.  If 
nothing else, the exception frame is huge.  I probably would have 
spotted it except for the indentation problem triggered by html.  The 
top level code following your function didn't have any loops, so it 
wasn't a problem.


Can anyone help Joshua put his gmail into text mode?




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


Re: Fatal Python error

2013-05-29 Thread Oscar Benjamin
On 29 May 2013 12:48, Joshua Landau  wrote:
> Hello all, again. Instead of revising like I'm meant to be, I've been
> delving into a bit of Python and I've come up with this code:

Here's a simpler example that gives similar results:

$ py -3.3
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def broken():
...   try:
... broken()
...   except RuntimeError:
... broken()
...
>>> broken()
Fatal Python error: Cannot recover from stack overflow.

Current thread 0x058c:
  File "", line 3 in broken
  File "", line 3 in broken
...

Under Python 2.7.5 it just goes into an infinite loop. Under Python
3.2.5 and 3.3.2 it crashes the interpreter as shown above.

What the broken() function is doing is totally stupid: responding to a
recursion error with more recursion. However this may indicate or be
considered a bug in the 3.x interpreter.


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


Re: Fatal Python error

2013-05-29 Thread Joshua Landau
On 29 May 2013 13:25, Dave Angel  wrote:

> On 05/29/2013 07:48 AM, Joshua Landau wrote:
>
>> Hello all, again. Instead of revising like I'm meant to be, I've been
>> delving into a bit of Python and I've come up with this code:
>>
>>
> To start with, please post in text mode.  By using html, you've completely
> messed up any indentation you presumably had.


Appologies, I use GMail and I don't know how to force text-only


>  class ClassWithProperty:
>>   @property
>> def property(self):
>> pass
>>
>
> Did you really mean to hide the built-in property?  I don't know if this
> does that, but it's certainly confusing.  And perhaps that's a difference
> between 2.x and 3.x


I'm not. That goes to self.property, whilst the normal function isn't. I
guess it does locally hide it, but who really cares? :P

You can rename it if you want. Anything will do. Obviously this is a
minimal example code, and not the real thing.

 As you will expect, this does nothing... on Python2.7 and PyPy. Python3.3
>> prefers to spit out a "Fatal Python error: Cannot recover from stack
>> overflow.", which seems a bit unexpected.
>>
>>
> A stack overflow means you have infinite recursion.


I realise, but I was hoping to catch that with the "except RuntimeError".


> Try fixing the property name above, and see if that makes a difference.


It does not make a difference.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >