Gimptalk - Premier Gimp Community: Python-Fu scripts not working at Windows although Python-fu - Gimptalk - Premier Gimp Community

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Python-Fu scripts not working at Windows although Python-fu

#1 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 30 October 2007 - 10:01 PM

Hello,

please, I've spent all the day to make it work, but unsuccessfully.
Python-Fu scripts in GIMP are not working on my system. When I
register() any new function, it is not possible to find it nowhere in
menu
. The only thing working is Xtns->Python-Fu->Console. The simplest
script I have been testing is located downhere..

I've tried to search all the google, but have found nothing, I'm
exhausted :(

===========I've all things needed:
WinXPpSP2
GIMP (gimp-2.4.0-i586)
gtk-dev-2.10.11-win32-1
python-2.5
pycairo-1.2.6-1.win32-py2.5
pygobject-2.12.3-1.win32-py2.5
pygtk-2.10.6-1.win32-py2.5

===========PyGTK demo also works:
  import gtk

  window = gtk.Window()
  window.set_title("PyGTK Test Window")
  window.show_all()

  gtk.main()


- new "PyGTK Test Window" is shown


===========Testing script resize.py:
from gimpfu import *

def Resize(img, drawable, width, height):
    pdb.gimp_image_undo_group_start(img)
    pdb.gimp_image_scale(img, width, height)
    pdb.gimp_image_undo_group_end(img)

if __name__ == '__main__':

    register(
        "redimensionar_imagen",
        "Redimensionar imagen",
        "Redimensionar imagen",
        "Javi Pacheco",
        "Javi Pacheco",
        "2005",
        "/Python-Fu/Ejemplos/1- Basico/Redimensionar imagen",
        "RGB*, GRAY*",
        [
            (PF_SPINNER, "width", "Ancho", 200, (0, 1000, 1)),
            (PF_SPINNER, "height", "Alto", 200, (0, 1000, 1))
        ],
        [],
        Resize)
    main()



=========== strange error message
When I try to run this script from Python console
(Xtns->Python-Fu->Console), error message is shown:
"..
gimp_env_init() must only be called once!
.."

When I remove the last line containing "main()", It seems everything is
all right, but still, there is none new function available in menu..


Please help,
crysman


PS: I have the indent of source code well formated in the .py file. Just here is displayed wrong..
0

#2 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 31 October 2007 - 01:39 PM

:s:

As far i know Python never worked in the Windows gimp version, ( well was rumours that was possible use it on Gimp 2.3 ...)at the point then support for it was disabled in all the installers.

This may be changed in Gimp 2.4 ...(but if so change was not too publicized)

If not i fear you may need to compile your gimp, to purposely (..try to..) add python support.



--------------------------------------------------------------------

But here i move in foreign territory..
.if i will need python i will more simply add a linux partition to my HD,

In linux Python works out of the box .....
in Windows...well i fear will be no simple, as far i know you may even become the first to do it successfully
0

#3 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 31 October 2007 - 05:57 PM

Hmm, that is strange, because if it is not supported, why is it offered during install process? And why the python console works? :((

http://www.imageox.n...-gimppython.png

http://www.imageox.n...-gimppython.png

"Edit: Changed images to links S-M"

Compile it myself.. What would I need? I never compiled on Windows, just on Linux.


I suppose it should be fixed by developers, anyway. Or removed from installation menu and documentation..
0

#4 User is offline   Sean-Michael 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 1,587
  • Joined: 02-May 05

Posted 31 October 2007 - 06:31 PM

I have also been interested in finding the missing key to this puzzle!

I got rather excited when I noticed this option with the fresh install of 2.4.0 but soon to my frustration, as I'm sure you found, it doesn't work as you would expect. Further more I find the lack of information a pain for someone like me that hasn't the time to research and put together the peaces. I can imagine a new gimper trying to figure this out'

Looks like you two have a good start here, but perhaps it would be good for the gimp community to reach out and ask someone to put together some information for us, weather it a developer or seasoned user.

I'm thinking buzzing the gimp.org irc channel or contacting someone threw the gimp home site to gather information for us?
0

#5 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 31 October 2007 - 07:27 PM

Well this should be asked on the Gimp developers list..

NOT SURE about IRC as you may notice its very hard find Gimp developers that may deal with Windows OS...more then 90% seems using only Linux...all the windows port seems done by a single developer (that doesn't even have access to a single computer with windows installed...at least so he stated time ago) another make the installer and finally a third one compiled most of the plugin available on windows ...not sure if there is a fourth one ,if any of them is often available on irc and i fear the others may be not able to help much

Quote

Hmm, that is strange, because if it is not supported, why is it offered during install process? And why the python console works?


I get no idea why you get a Python console i have not on win, neither i notice a option for PY during install
Since Gimp code is multi platform, may be even possible that who compile for win forget to disable it,since that is (was?) a issue only in Windows versions

But is not clear: Gimp-python support for windows OS was supposed to be solved in gimp 2.3 ...so, in theory should be possible get it on 2.4 (if changes where successful and if where maintained in 2.4)
0

#6 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 31 October 2007 - 07:50 PM

PS Maybe i didn't see the enable Phython option when installing because i previously unistalled Python 2.5? ...that will make sense
0

#7 User is offline   Sean-Michael 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 1,587
  • Joined: 02-May 05

Posted 31 October 2007 - 08:44 PM

Yea, there are many questions here.

Many times I have gone to the gimp.org irc channel and gotten good information, other times I have not but it is worth a try to get some enlightenment on the subject.

I've never been active on the Gimp developers list, it would be most helpful for you to inquire there for information, possibly invite them to share somewhere if this isnt a dead hoarse, I will do the same on the irc channel, even the [GuG] list.

Just seems that they have meant to bridge a gap, weather it was done or meant to be released at this time is not clear! Wish I had more time for this one :l:
0

#8 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 31 October 2007 - 09:27 PM

I wish the same, man. You cannnot imagine how many hours I spent trying to solve this problem and figure out, configuring, reinstalling, typing in google, even reading tutorials in spanish!

I thing I will try some day to post it to developers as you suggest, because I would really like to make some scripts in GIMP and I don't like that "Scheme -fu thing".. I don't know much Python, either, but the language seems more friendly to me (since I've been doing some scripts in PHP)

Thanks a lot for participating, though!
crysman
0

#9 User is offline   PhotoComix 

  • GT Senior Moderator
  • Group: Senior Moderators
  • Posts: 11,288
  • Joined: 13-June 05

Posted 31 October 2007 - 09:43 PM

well for sure you will spend much less time posting the list

Also the yahoo-gimp win user group is a good place for ask
0

#10 User is offline   Sean-Michael 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 1,587
  • Joined: 02-May 05

Posted 31 October 2007 - 10:17 PM

Yea, I have the steps for getting python working... It'll take me a little to write up a tip post and instructions but it looks as if you "crysman" have more then what is needed. I just want to tip you to something in case you dont know.

Put your python scripts in the user plug-ins directory, "C:\Documents and Settings\Sean-Michael\.gimp-2.4\plug-ins".

a working script I used is here,
http://registry.gimp.../plugin?id=8904

As for the scripting thoughts you mentioned, I understand, I also learning php and see the similarity.
0

#11 User is offline   Sean-Michael 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 1,587
  • Joined: 02-May 05

Posted 31 October 2007 - 11:39 PM

I've posted what I was told here
http://www.gimptalk....ast.html#194408

I still am interested in getting python and 2.2 working, but that seems more involved and I dont have that kind of time right now. :w:

Happy Gimping'
0

#12 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 01 November 2007 - 12:45 AM

Quote

Put your python scripts in the user plug-ins directory, "C:\Documents and Settings\Sean-Michael\.gimp-2.4\plug-ins"

Sure, I had it there..

Interesting!

"Your" script works! I have to find out why the others don't... especially my test script, for the first look I cannot see any difference..

When I get it, will post it here

crysman


PS: thanks for help, pal!
0

#13 User is offline   Sean-Michael 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 1,587
  • Joined: 02-May 05

Posted 01 November 2007 - 01:20 AM

I'm just glad to been of some help, perhaps as a mediator but none the less, a little help.

Just for the record, I didn't write the script, just used it to test.

HAPPY HALLOWEEN!
0

#14 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 01 November 2007 - 02:16 AM

Quote

Just for the record, I didn't write the script, just used it to test.

I know, thats why I used "Your" (in quotation marks)

Quote

HAPPY HALLOWEEN!

Thanks, now it is, I found the problem. You wont belive this! Btw, we don't celebrate Helloween and I have 4:45 in the morning right now.. So, happy Halloween to You! :)


The problem is in characters with accents in comments! Incredible! I thought that interpreter of Python ignores everything what is behind '#' char.. But obviously not..

See the picture:
http://www.imageox.n...-gimppython.png
The script on the left doesn't work, whereas the script on the right does. Green lines are showing the lines which differ. I've added red circles to mark what exactly differs on each line..

CONCLUSION:
Don't use any characters with accents in your scripts! Use just 7-bit ASCII
(first 128 chars) to be safe..

good luck to everyone and thanks for help
crysman
0

#15 User is offline   Sean-Michael 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 1,587
  • Joined: 02-May 05

Posted 01 November 2007 - 02:44 AM

That's awesome!

I was trying to get back to your original problem of your script error. You found it much faster then I would have, We look forward now to seeing some great plugins/scripts from you :w:
0

#16 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 01 November 2007 - 02:52 AM

You couldn't find it, because I've pasted the script here without all comments (to make it shorter).

Thus, there is a big lesson in this for me (and everyone else):
Always paste exactly the same what you've been testing to run..

Quote

We look forward now to seeing some great plugins/scripts from you

:l:

So, I thing we might consider this thread closed, don't we?
0

#17 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 01 November 2007 - 06:55 PM

Just one more thing (if anybody still watch this thread)..

Is it possible in any way to have some debug informations about python scripts in GIMP? Because "binary" debug like "works/doesn't work" is really awful! Writing scripts with this most primitive debug (no debug at all) is very painful! If you have in mind the fact, that GIMP needs to be restarted every time when there are changes in the script.. :s:
0

#18 User is offline   saulgoode 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 5,324
  • Joined: 22-August 05

Posted 01 November 2007 - 08:28 PM

The Python-fu plugin is different from the Script-fu interpreter because it is actually implemented as a separate program from GIMP (which accesses GIMP's libraries). You might find the information available in this document useful.
Everybody makes their own fun. If you don't make it yourself it's not fun, it's entertainment.
0

#19 User is offline   crysman 

  • Member
  • PipPip
  • Group: Members
  • Posts: 11
  • Joined: 30-October 07

Posted 01 November 2007 - 09:28 PM

Quote

The Python-fu plugin is different from the Script-fu interpreter because it is actually implemented as a separate program from GIMP (which accesses GIMP's libraries). You might find the information available in this document useful.


But I am (unfortunately) using windows binaries.. So It's different from the document proposed above.. Thus, the question is: Anyone knows how to debug python scripts on windows?
0

#20 User is offline   Sean-Michael 

  • Retired Staff
  • PipPipPip
  • Group: Retired Staff
  • Posts: 1,587
  • Joined: 02-May 05

Posted 02 November 2007 - 04:41 AM

I try to ask your questions for you but I have a hard time elaborating for you as I'm sure you can understand.

I went to the gimp irc channel again and asked your question and was told to use the console, so I tried it with your posted script above and got this...

Quote

from gimpfu import *
File "", line 1
gimpfu import *
^
IndentationError: unexpected indent
>>>
>>>
>>>
>>> def Resize(img, drawable, width, height):
...
... pdb.gimp_image_undo_group_start(img)
...
>>> pdb.gimp_image_scale(img, width, height)
File "", line 1
pdb.gimp_image_scale(img, width, height)
^
IndentationError: unexpected indent
>>>
>>> pdb.gimp_image_undo_group_end(img)
File "", line 1
pdb.gimp_image_undo_group_end(img)
^
IndentationError: unexpected indent
>>>
>>>
>>>
>>> if __name__ == '__main__':
...
...
...
... register(
...
... "redimensionar_imagen",
...
... "Redimensionar imagen",
...
... "Redimensionar imagen",
...
... "Javi Pacheco",
...
... "Javi Pacheco",
...
... "2005",
...
... "/Python-Fu/Ejemplos/1- Basico/Redimensionar imagen",
...
... "RGB*, GRAY*",
...
... [
...
... (PF_SPINNER, "width", "Ancho", 200, (0, 1000, 1)),
...
... (PF_SPINNER, "height", "Alto", 200, (0, 1000, 1))
...
... ],
...
... [],
...
... Resize)
...
Traceback (most recent call last):
File "", line 5, in
NameError: name 'register' is not defined
>>> main()


To me it looks like it is working, I simply copy and pasted and the output was automatic...

I think it would be a great resource for you to start using irc if you do not already... if you are using firefox, and chatzilla simply click the link below to warp to the gimp.org irc channel.

irc://gimp.org/gimp

Hope this helps you!
0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic