SPE 0.8.4.b improved for Blender 2.45

Witold put some great effort to make SPE catch up with the latest Blender 2.45 It is now available for testing in the subversion repository:

Now debugging (with breakpoints, changing variables on the run, …) should be more easy as well. Don’t thank me (I just tested and accepted his patches), but give a big thanks to Witold!! All credits go to him! I hope Witold agrees to answer here to further questions. He also will prepare a tutorial on how to develop scripts with SPE and how to debug scripts in Blender. If you want to help him, please let yourself be heard. This might give the ultimate tool to develop more serious python scripts for blender.

SPE 0.8.4.b runs on Windows, Linux & Mac. I use ubuntu gutsy as the main development platform for SPE.

Stani

From his email conversation:
I have started to use your editor, because it is the only one will be useful to write the scripts in Blender. I have found, that the original version 0.8.3.c has a lot of flaws, when it comes to cooperation with Blender 2.43.

Fortunately, it was not too difficult to fix these things, and I just have appended the description of these adjustments to this e-mail. Maybe you will find them useful for another version?

In general, I have found that most of the SPE 0…8.3.c commands, concerned with Blender, although obsolete, can be transformed into alternatives that are available in Blender 2.4: automatic adding scripts to Blender’s menus, loading into text editor, etc.

I have also used the Winpdb to debug scripts inside Blender, but, in fact, in this case this product is not used from within SPE, but as another product.

Usual pattern of work on Blender scripts was:

  • load SPE from Blender (new shortcut appends it automatically to Blender Scripts–>System menu).
  • create a new script in SPE;
  • optionally: add it to the Blender menu, using SPE command “Reference in Blender”
  • edit the file in SPE,
  • to test: load updated file version into Blender’s Text Editor, using SPE command “Load in blender”
  • close SPE
  • set tracking by WinPdb
  • run the script from Blender’s Text Editor - this enter the debuging in Win Pdb
  • when the bug was found - detach Winpdb and call again SPE, if the changes are more serious (small adjustments can be added directly in the Blender’s text editor)

best regards

and thank you for the SPE

Witold Jaworski

I miss SPE, as I had thought this would be the perfect IDE to help me learn Python via Blender.

I never used an SVN before, so the instructions at your site were helpful and easy. I think I may have messed something up, though. Here is the import error I got in the terminal when I Alt+P the SPE.blend file:

Compiled with Python version 2.5.
Checking for installed Python... got it!
Traceback (most recent call last):
  File "SPE.py", line 32, in <module>
ImportError: No module named info
Traceback (most recent call last):
  File "spe editor", line 13, in <module>
ImportError: No module named _spe.SPE

When I installed the SVN client, I checked out SPE into a folder I made on my drive. Now I am wondering if the import error is cause because I need to set a system %PATH% variable or something.

Until I hear from you, I think I’ll mess around trying to set a variable and stuff to see if I can get the long awaited SPE to work on my PC.

Thanks in advance, for any and all advice and suggestions.

Edit:

;C:\MySPEfolder\SPE.py or ;C\MySPEfolder\spe_blender.py   , or spe.blend.py 

? is it one of these .py files in here, or should I look in sitepackages in Python25 folder?

Yeah, thanks Stani and Witold. Cool:cool:, Stani is back “on stage”. And SPE is better than ever.

@dukytyme
Witold was using a spe.pth file to solve the issue for the path. However he has promised to look into it and fix the spe_blender.py script. So let’s wait for that.
Can you first try if you can launch spe outside blender, just on its own. It is important that you don’t rename the _spe folder. You should be able to launch spe with:
python SPE.py

if it doesn’t work, please do
python SPE.py --debug

(pythonw on mac)

I have not updated the spe.blend file, yet (sorry for this). I am just prepare the proper version today.
Anyway, you can still use the SPE in Blender:
just copy the spe_blender.py file from the Python Lib\site-packages_spe directory to Blender .blender\scripts directory, or your user script directory, if you have registered such in Blender user preferences.
The existence of this file there will extend your Blender’s Scripts menu (on the Scripts Window panel) with System–>Stani Python Editor command.

Witold has sent me the spe.blend file as well as some other modifications. I have applied them in subversion:

Sending spe.blend
Deleting spe.blend.py
Deleting speMac.blend
Sending winpdb_blender.py
Transmitting file data …
Committed revision 269.

If you have downloaded spe before with svn you can simply update to the latest version by going to the _spe folder and doing:
svn update

Or if you use tortoise svn in windows. Right click on the _spe folder and choose update!

Can please linux users and mac users test this? I’d like to bring a new release of SPE out, but this won’t work if we don’t have testers. So are you playing with python in blender, we need YOU!

Thanks,
Stani

My spe_blender.py was not located in the Python25 or 24 lib/sitepackages…It was located in the main spe directory. I guess I messed up the installation; I assumed I was ok to SVN spe to a new folder of my choice on c: drive. I gave that folder a name before I ran the SVN, it is not called spe.

I ran spe_blender’py that was located in my “pre-named” spe folder, and my “Open with” dialog came up. I nav’d around and had no clue what file was going to run spe, and some where .py no console, .py, and just unrecognized “file” by my system.

There is a “SPE_DEBUG.py” file located in the directory, but the same happens when I run the debug command.

I think I just messed up the install. I should start over, and SVN to a folder called _spe. right? Because if I did not chose a pre-named folder, tortoiseSVN would spew files all over my c: drive.

Yes, I think it is better to start from the begining :yes:.

  1. Get the actual SPE version, and place it in Your Python\Lib\site-packages_spe direcory (this underscore is important!). For example, on my computer I have placed Python at "C:\Program Files\Python", so full path to the spe.py file on my computer is “C:\Program Files\Python\Lib\site-packages_spe\spe.py”. Python can be placed in other directories - you can also install it at “C:\Python25” or something like this. No problem, as long, as the structure of directories INSIDE Python directory remains fixed.
  2. The easy way to open SPE from Blender (for the novice users): open Blender, and load the _spe\spe.blend file. You will see the Text Editor at the bottom, when you run the script inside it, SPE will open.
  3. The normal way to use SPE from Blender:
    copy two files from _spe\ directory:
    spe_blender.py
    spe_winpdb.py
    into Your Blender.blender\scripts\ directory, then open Blender. In Blender open the Scripts Window in any of its areas.
    You will find in Blender Scripts Window a Scripts menu, there is System submenu, an there two commands:
    “Attach Winpdb debugger”
    “Stani Python Editor”
    They are the shortcuts to the scripts, you have copied to Blender.blender\scripts\ directory.
    One runs SPE, the other - debugger, delivered together with SPE (to debug Python scripts inside Blender).
    I am working on a tutorial, how to use SPE and Winpdb in Blender. I hope, that I will be able to present it on November .

Yay!

It worked exactly like and how you have said. How am I ever going to be able to create anything in Python, if I cannot pay attention to details…Like the very clear details on the spe site?

Works fine both ways, from loading the spe.blend and from the scripts menus. Thanks very much.

I try locate spe.blend with :

locate _spe/spe.blend
/usr/lib/python2.4/site-packages/_spe/spe.blend
/usr/lib/python2.4/site-packages/_spe/spe.blend.py
/usr/lib/python2.4/site-packages/_spe/spe.blend.pyc
/usr/share/pycentral/spe/site-packages/_spe/spe.blend
/usr/share/pycentral/spe/site-packages/_spe/spe.blend.py

I use blender-2.45-RC2-linux-glibc236-py24-i386 ( you see python 2.4)
I open the spe.blend with blender from here

/usr/share/pycentral/spe/site-packages/_spe/spe.blend

and error is :

Compiled with Python version 2.4.1.
Checking for installed Python... got it!
Traceback (most recent call last):
  File "spe editor", line 13, in ?
  File "/usr/lib/python2.4/site-packages/_spe/SPE.py", line 11, in ?
    import info
  File "/usr/lib/python2.4/site-packages/_spe/info.py", line 51, in ?
    import sm.osx
  File "/usr/lib/python2.4/site-packages/_spe/sm/__init__.py", line 33, in ?
    from python import *
  File "/usr/lib/python2.4/site-packages/_spe/sm/python.py", line 2, in ?
    import sm
  File "/usr/lib/python2.4/site-packages/_spe/sm/__init__.py", line 33, in ?
    from python import *
  File "/usr/lib/python2.4/site-packages/_spe/sm/python.py", line 12, in ?
    import math,random,string,time
  File "/usr/lib/python2.4/random.py", line 67, in ?
    import _random
ImportError: /usr/lib/python2.4/lib-dynload/_random.so: undefined symbol: _PyArg_NoKeywords

so i try with this :

/usr/lib/python2.4/site-packages/_spe/spe.blend

and error is :

Compiled with Python version 2.4.1.
Checking for installed Python... got it!
Traceback (most recent call last):
  File "spe editor", line 13, in ?
  File "/usr/lib/python2.4/site-packages/_spe/SPE.py", line 11, in ?
    import info
  File "/usr/lib/python2.4/site-packages/_spe/info.py", line 51, in ?
    import sm.osx
  File "/usr/lib/python2.4/site-packages/_spe/sm/__init__.py", line 33, in ?
    from python import *
  File "/usr/lib/python2.4/site-packages/_spe/sm/python.py", line 2, in ?
    import sm
  File "/usr/lib/python2.4/site-packages/_spe/sm/__init__.py", line 33, in ?
    from python import *
  File "/usr/lib/python2.4/site-packages/_spe/sm/python.py", line 12, in ?
    import math,random,string,time
  File "/usr/lib/python2.4/random.py", line 67, in ?
    import _random
ImportError: /usr/lib/python2.4/lib-dynload/_random.so: undefined symbol: _PyArg_NoKeywords

I copy the spe_blender.py in /.blender/scripts but in System i have only 2 scripts :
Interactive console
Scripts config editor …
Some help, please !!!

I think, that you should check, if it is possible to run SPE as a standalone editor, not within Blender. From the tracebacks, you have enclosed, it seems a kind of a problem in the editor, not specific to Blender.
Let us know, about the result.
I’ll have to ask Stani to chceck this error, because I am not using an unix system.
About the missing commands in the Scripts–>System menu: let’s first check, if SPE is working on your computer, maybe these two errors are related to each other. Anyway, you can try this:

  1. In Blender, open User Preferences Window, and press the “File Paths” button
  2. In Scripts: // item (at the bottom of second column of inputs) select the path, where you have placed the spe_blender.py and winpdb_blender.py
  3. At the right corner of this input you have an additional small button, which has tooltip: “Re-evalute scripts registration in menus”. Press it.
    Maybe these three steps will bring you these two commands to Scripts–>System menu, but most probably you will ecounter the same error, as described, during loading the SPE.
    So let us know, if you can run SPE standalone :confused:

I’ll ask the obvious for those of us that are not informed.

What is SPE?

SPE means “Stani’s Python Editor”. It is a Python editor written in Python by Stani Michels. It can be used, together with the Winpdb Python debugger, written in Python by Nir Aides.
Both programs forms a kind of rich IDE, which can be run inside Blender. You can make Python Scripts in Blender much more faster and easier with them, than using standard tools, delivered with Blender. (Text Editor window, Interactive Console script, …)
For more information see:
SPE: http://pythonide.blogspot.com/,
Winpdb: http://www.digitalpeers.com/pythondebugger/

It looks like you have only a minimal installation of python2.4 You do not have python default libraries installed such as random which fails to load (import random).

In Ubuntu/Debian you can probably fix this by installing python2.4:

sudo apt-get install python2.4

i’ve got the same problem as mythcat using blender-2.45-linux-glibc236-py24-i386 on debian etch
i have the full version of python 2.4 installed (not minimal).

[UPDATE:] it works when starting blender like this:

LD_PRELOAD=/usr/lib/libpython2.4.so.1.0 ./blender

…so the dynamic linker uses this explicit lib.
kindof strange and shouldn’t be, though.

Hi

Has anyone got this working on Windows with Blender 2.45 ? I am getting the error message “Import Error no modulle named _spe.spe”

This is when I click on the scripts->System->Stani Python Editor

I have set my scripts path to point at “c:_spe” but it makes no difference

I can run SPE standalone OK without a problem
Any help as to what I am doing wrong would be appreciated

Thanks

Geoff

I left Stani and message about this very problem on his blog. http://pythonide.blogspot.com/
But have not gotten and response.

I am working on Windows, with Blender 2.45, and, in fact, this shortcut in Blender it is my part of the code.
You should not install _spe folder on C:_spe, if you do not want to manually update the PYTHONPATH. You have obtain this error, because Python is not able to find the spe.py module. This is because your C:\ directory is not on the PYTHONPATH. (not C:_spe, as GeoffW has probably did: This error message means, that Python tries to find _spe directory on its search path, and inside it a spe.py file). It is not very elegant to add C:\ to the directories searched by the Python interpreter, anyway you can try to do this.
The easier way of resolving this problem is to move the _spe directory to its default location - inside your current Python version folder, in Lib\site-packages directory
Look at my answer to dukytyme, form 30th October, in this thread, if you have doubts about the default _spe file location on Windows.
Let me know, if it has resolved your problem

Ok not only had this not resolved the problem, it has made it worse. I used to have SPE in a folder in C:\Documents and Settings\Owner\Desktop\7zip_spe. This is where I put it when I followed stani’s instructions for using tortisesvn to download the most recent version. That was back in august.
Ok I just followed your instructions and moved that folder to C:\Python25\Lib\site-packages. Where is it now C:\Python25\Lib\site-packages_spe. I moved the two files that you mentioned in your October 30th post: spe_blender.py and a file named “winpdb_blender.py” to the C:\Program Files\Blender Foundation\Blender245.blender\scripts\ directory. By the way you said in that October 30th post to move “spe_winpdb.py” which does not seem to exist in my the _spe folder that i moved so, but I think that “winpdb_blender.py” file is the correct one.
In anycase. Now I cannot start SPE from the desktop shortcut that I previously was using. I click on the shortcut and nothing happens. Just nothing. So I opened the properties of the shortcut and corrected the "Start in " path to the new locations of the _spe folder. STill nothing happens.
I tried using the two now submenu items inside blender 2.45 Scripts Menu—>System Submenu----Attach Pdb debugger and I get a popup that says “Error: Check console window” and in the console window I get “Compiled with Python version 2.5.
Checking for installed Python… got it!
Spe Error: Please install the right version of wxPython: 2.6.1.0.
No module named wx
Traceback (most recent call last):
File “<string>”, line 74, in <module>
File “C:\Python25\lib\site-packages_spe\plugins\spe_winpdb.py”, line 31, in <
module>
import wx
ImportError: No module named wx”
When I try the submenu item Stani Python Editor. Both the blender window and the blender console window just close without any errors

So to sum up. After following your advise. NOW not only can I not use SPE in Blender. I cannot get SPE to run AT ALL!!!

Hi Witold

Thanks for the help

On your advice I copied my entire _spe folder from c:\ to C:\Python25\Lib\site-packages\

That solved the problem, I can now get SPE to start up from Blender by clicking on

Scripts->System->Stani Python Editor

After SPE opens with a blank edit screen Blender seems to be in a locked state where I cannot do anything.

At this point my brain is in a similarly blank state :smiley: I am lost as how to proceed to be able to debug my own Blender python script.

You mentioned you were working on a tutorial for this, how is that going ?

Myself and probably a few others are keenly waiting for this tutorial, this stuff is not easy to get working by guesswork.

Thanks again

      Geoff