Python erros

Hello, I have been playing wih MRL for two weeks now an I cannot get anything to work so I am hoping that someone can help me.

I am running on a windows machine with 12 GB of ram.

I am trying to run the inmove2.ear and mouth talk.py

Any script I run does not work. I know it has to be sonthing I am doing.

I sent a no-worky.

the error I get is 34534 [Thread-7] ERROR class org.myrobotlab.framework.Service  - Python error - ------Traceback (most recent call last):

Thanks
Bill
GroG's picture

Hello and Welcome BillC,2

Hello and Welcome BillC,

2 Weeks ! ..   you should ask sooner ! ;)

2 Things :

  1. I saw your no worky .. it looks like you sent it before you ran a script ..  You should run a script, and if you get an error send the noWorky then ..  A noWorky is simply the log file of what has happened.
  2. I think your looking in the toSort directory of scripts .. This would probably be better - https://github.com/MyRobotLab/pyrobotlab/tree/master/service 
    let me know how it goes...
BillC's picture

Thanks

Thank you. I will give it a try and let you kmow.

BillC's picture

Still not woking

Hello GroG, I did go to the link that you gave me and I downloaded speech,py the first time i ran it

worked fine. But when I tried to run it again it did not work.

I sent you a no-worky.I hope I did it right this time.

Thanks

BilC

GroG's picture

Yeah .. got the noWorky !  

Yeah .. got the noWorky !   Good !

The problem is probably because you saved it and then re-loaded it possibly ..
There are now only carriage returns in your script you can solve this easily 2 ways.

  1. Always get the "raw" version of the file from github .. and try again (raw button) -
    Here's the direct link https://raw.githubusercontent.com/MyRobotLab/pyrobotlab/master/service/Speech.py
  2. Use TextPad to convert to Linux ASCII text file.

Tell us if you can "consistently" re-create the problem .. Thanks..

BillC's picture

Thanks for the quick

Thanks for the quick responce. I always get the raw version. I do a copy and then I paste into notepad +++

and then do a save as xxxx.py Could that be my problem? 

kwatters's picture

Python cares about white space..

Hi BilC,

  I just saw the error message you are seeing

...

51637 [Thread-9] ERROR class org.myrobotlab.logging.Logging  - ------
SyntaxError: ("mismatched character '\\r' expecting '\\n'", ('<string>', 2, 53, '\n'))

...

As it turns out, python is sensitive to files that end in a CR/LF.  It's a difference between Windows and Linux in how it formats text files.

Python is sensitive to these line endings.  So long story short, the way that you are cutting & pasting the python script into the python window in MyRobotLab is including these "hidden" characters..  perhaps you notice it as extra blank lines.. or something..

If you typed the script in manually, you would not see this error.    

Basically, what ever text editor you are using is mangling the line endings..   I think perhaps if you just cut & paste it into notepad..  that might do it correctly for you..  

What program are you using to create this script?  I see you're using microsfot windows...   I'm just thinking what ever program you are editing the text in is the culprit here.  

That being said, this would be a nice thing to fix so you don't have to worry about these details...

 

BillC's picture

Hello, I am using notepad +++

Hello, I am using notepad +++ could that be my problem?

btw thanks for the quick response.

 

BillC

kwatters's picture

Specify line endings in your editor

I don't personally use notepad++ , however I found this link that shows how to set the line endings.

http://www.larshaendler.com/2013/06/10/notepad-unix-to-dos-line-endings/

You can try "unix" style line endings.... save the file that way..  then in MRL you should be able to open it up and running it to avoid the \r\n error messages.

As GroG mentions, this happens if you save the file from inside of the python editor in MyRobotLab, I've seen the problem before also.  We'll have to put this on the TODO list to fix this to make it handle this slight issue between windows/linux/mac...

I've created an issue  https://github.com/MyRobotLab/myrobotlab/issues/14 to make this work easier 

in the mean time you could try fiddling with the line endings setting in notepad++

 

hope this helps!  

BillC's picture

Ok I will try that.   Thanks

Ok I will try that.

 

Thanks

kwatters's picture

new release available

If you continue to have problems with the CR/LF thing.  I just created a new build that should fix this issue for you

https://github.com/MyRobotLab/myrobotlab/releases/tag/1.0.104

This release will hopefully make this issue go away for a long time..  if you want.  test it out with the same method and tools you were using.  the goal is to make sure MRL works for everyone.. and people don't have to deal with issues like this..

 

hope it helps and works for you!

 

GroG's picture

Kwatters ! - 

Kwatters ! - 

BillC's picture

Thank you I will give it a

Thank you I will give it a try and let you know.

 

Thanks

BillC's picture

Still having problems

Hello, this is what I found so far. If I type in a script some of them will work others will not.

I have tried the following Python scripts.

1. clock ----------------------------------------------------------------- works jut fine

2. speech -------------------------------------------------------------  works just fine.

3. InMoov2 ear and mouth talk-----------------------------------  does not work

 I sent you a no-worky.

Please let me know what I am doing wrong.

 

Thanks

Bill

kwatters's picture

one problem solved new ones exposed.

So, great news, the original error with the wierd line endings is fixed... now it's a matter of syntax and python programming that is causing the error.

From your no worky (posted relevant part is posted below)

the script is trying to invoke   :

"i01.head.jaw.setMinMax(6,30)"

Problem is the head hasn't been started yet, so you're getting this error below saying "jaw" doesn't exist yet..  

looks like we need to update the example scripts you are using..  

update your script to add the line "i01.startHead(headport)"  after you create the i01 (inmoov) service.

 

headport = "COM3"

i01 = Runtime.createAndStart("i01", "InMoov")

head = i01.startHead(headport)
 
 
That should make sure the jaw is created before it tries to set the min/max values for it.
 
29096 [AWT-EventQueue-0] INFO  class org.myrobotlab.control.ServiceGUI  - buildLocalServiceGraph-end
29096 [Thread-7] ERROR class org.myrobotlab.logging.Logging  - ------
Traceback (most recent call last):
  File "<string>", line 4, in <module>
AttributeError: 'NoneType' object has no attribute 'jaw'

	at org.python.core.Py.AttributeError(Py.java:166)
	at org.python.core.PyObject.noAttributeError(PyObject.java:930)
	at org.python.core.PyObject.__getattr__(PyObject.java:925)
	at org.python.pycode._pyx3.f$0(<string>:15)
	at org.python.pycode._pyx3.call_function(<string>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1261)
	at org.python.core.Py.exec(Py.java:1305)
	at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)
	at org.myrobotlab.service.Python$PIThread.run(Python.java:129)
------

29096 [Thread-7] ERROR class org.myrobotlab.framework.Service  - Python error - ------Traceback (most recent call last):
BillC's picture

It still not work

Hello, Thanks for all your help. I have tried all things you told me .

However the InMoov2ear and mouth talk does not work still.

I sent a no-worky  but I am about to give up. Does it matter were I keep the script file?

 

Thanks

BillC.

kwatters's picture

resistance is futile

The location of the script doesn't (shouldn't matter)... resistance if futile, we will make it work  :)

The good news is some of the scripts are working now ..and you're running into new issues.  We don't really keep up on testing and updating scripts that have been added by the community.  (though that'd be a great thing to do in the future)

In general, the scripts that are in the pyrobotlab github repository are really intended to be examples of things you can do.  One of the fullest examples is Gael's InMoov full2 script.

https://github.com/MyRobotLab/pyrobotlab/blob/master/toSort/InMoov2.full.py

I can take a look at the ear and mouth 2 talk script (I think you're referring to this one   https://github.com/MyRobotLab/pyrobotlab/blob/master/toSort/inmoov2.ear%20and%20mouth%20talk.py )  

 

BillC's picture

Yes that is the

Yes that is the one.

 

Thanks.

GroG's picture

That script is very old ..

That script is very old .. I'd recommend not trying scripts  in the toSort directory..
They are to be sorted, and evaluated and deleted if not applicable anymore - you found one which is very old and will be deleted...

The ones in the service directory - if you find and issue with we will fix as quickly as possible.

The ones in the home/(user) directory is really the users script and you'll know who to contact directly for questions.

Hope this helps.

BillC's picture

Ok , I will do that. Thank

Ok , I will do that.

Thank you for all your help.

BillC