Blender is said to have perfect Python scripting capabilities. I just cannot find an environment, where I could try it all. Can you give an advise for the noob?  I have a problem with defining an environment for python coding. Once I complained about inability to use keys to select the current command line the command line or even delete it, IRC advised that command line is bad, especially because I also should not define any functions in it. I should better use the Text Editor instead.  However, I have discovered that I cannot run the Text Editor-defined scripts in the command line. Basically, I should forget about the command line and do everything in the Text Editor. Fortunately, it has the Run Script button. However, it is very boring to save every script before running. I better used external editor if I need to save the file before running it anyway. It also does not display me the errors. How can I program anything without seeing the errors. It says that my error msg was printed somewhere into unknown console. I came back to the command line but its view is too tiny. Can I make it in another window to switch easily between the 3D scene and the pycommand line? Probably, you have a better advise to make the operational python environment.  I hoped that I can store the successul lines of code in external editor and fiddler them into the console. But the following lines  for o in D.objects: o.select = True ; bpy.ops.object.delete() earth = bpy.ops.mesh.primitive_uv_sphere_add()   succeed only if I paste them one-by-one and fail if I paste them two at once.
124110
I'm trying to figure out a good workflow for developing scripts and add-ons in Blender. Here's what I'm currently doing as I try my luck with a PyNode add-on:   Open blender Create a text editor panel Open my script (external text file) Edit my script in a nice external editor Reload the script Save the .blend file Run the script   Now that I can see what my code does, this Blender instance has been modified, so I can't (make changes to my script and) run my script again. So I do this:   Close blender Open blender with the .blend from step 6 and repeat steps 4-7, over and over and over..   Is there a better workflow for this sort of thing?
20404
At the risk of posting a duplicate question: How can I run a local script (as the current user) when I log out? I read (and tried) among others:   (Marton's version), which did perfectly nothing, used on a simple script creating a file, absolute paths to the script (being executable) and the file. , which must be outdated; it made me remove the file from command line to be able to use my system again. I also looked into , without succes.  I believe I must be doing something wrong here, but cannot find out what is my blind spot. Context Looking for an elegant solution (workaround) to , presumably the result of a bug, I made a script that, depending on the argument, either takes a snapshot of the current desktop icon arrangement, or arranges the icons, according to the last snapshot. The script works fine, but is really no candidate to run as a background script. The script therefore should run on logout to get the arrangement, obviously run by the current user.
121103
Is there a GUI IDE for programming python just like java has netbeans?  I wanted one where we could drag &amp; drop test boxes &amp; labels just as we do in swing components using netbeans or eclipse.  Or is there an add-on present in either netbeans or eclipse itself?
111531
I have written up a script for my model. But there is a bit of a problem with it. As in I have to run the script every time I open the file. I want the script to run automatically when I open the blender File.
31179
I am using Sublime Text 3 in Ubuntu. The default Python is python2 which Sublime uses when I build program using Ctrl+B. I am trying to run code as, print(f&quot;Player {row[0]} Vertically =&quot;)  but it gives error as follows because code is run with default Python File &quot;/home/gd/Desktop/python/python-revision/pp_13_iterators_iterables.py&quot;, line 41   print(f&quot;Player {row[0]} Vertically =&quot;)                                       ^ SyntaxError: invalid syntax [Finished in 0.0s with exit code 1] [shell_cmd: python -u &quot;/home/gd/Desktop/python/python-revision/pp_13_iterators_iterables.py&quot;] [dir: /home/gd/Desktop/python/python-revision]  However, when I run same program from terminal, using python3 it works as expected. $ python3 pp_13_iterators_iterables.py [1, 2, 1] [2, 0, 1] [1, 2, 1] Vertically Player 1 Vertically =  How can I change default build environment of Sublime Text to Python 3 and build it using shortcut as Ctrl+B? I tried using alias as alias python=&quot;/usr/bin/python3.6&quot;  but it didn't work and gave same error as previous.
62604
When Blender is installed, it creates its own copy of Python 3.x. However, I prefer to code in Python 2.x. This makes it difficult for me to work with newer versions of Blender. I would like to know what to do so that Blender will instead use an external installation of Python 2.x, which I already have installed on my computer.  How do I make Blender recognize the other version of Python?
37396
Can you please tell me how to remake it for Blender 2.8x version?  def register():     bpy.utils.register_module(__name__)     bpy.types.INFO_MT_file_export.append(menu_func_export) def unregister():     bpy.utils.unregister_module(__name__)     bpy.types.INFO_MT_file_export.remove(menu_func_export) if __name__ == "__main__":     register()
53643
So, I am following a , and it is using Python code to create an audio visualizer in Blender. Now, I've always been a coding geek, but I don't actually know Python. I've taken a few shots at it but overall, I don't know Python, however, I can read and understand the code because I know basic programming concepts. Now, I'm following this tutorial as closely as I can (the tutorial does not provide code to copy and paste) and I am getting a syntax error. As far as I can tell, there is no syntax error. The line of code (specified by the error message) appears perfect. This line of code is supposed to set the 3D cursor to the active object's origin. Here's the catch: if I run that exact same line of code in the console, it executes just fine. So here's the error message I get:  File "C:\Me\Blender\Blender Projects\audio visualisation.blend\AudioVisualizer", line 17 bpy.context.scene.cursor_location = bpy.context.active_object.location    ^ SyntaxError: invalid syntax location: &lt;unknown location&gt;:-1   It tells me to look in the console for error message, but the console doesn't output anything.    Thanks!  EDIT: Alright. I've tried all the examples and all the procedures that have been suggested by you guys, but it keeps feeding me errors. According to the console, one of the problems it is spitting out is in C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\bpy\ops.py. This makes me think there is a bug in the API that is causing one of the many errors. EDIT: Here are the error messages I get for my code. Original Code:  Error:   File "C:\Gannon\Blender\Blender Projects\audio visualisation.blend\Audi o Visualizer", line 35     bpy.ops.graph.sound_bake(filepath="C:\Gannon\Blender\Sounds\Music\Batty McFa dden.mp3", low=i*step high=i*step+step                           ^ SyntaxError: invalid syntax    gandalf3's Code and zeffii's Code are essentially the same with alternative formatting which changes the line numbers where the error occurs.  Error: Unsupported audio format  Traceback (most recent call last):   File "C:\Gannon\Blender\Blender Projects\audio visualisation.blend\Audio Visua lizer", line 42, in &lt;module&gt;   File "C:\Gannon\Blender\Blender Projects\audio visualisation.blend\Audio Visua lizer", line 35, in spiral   File "C:\Program Files\Blender Foundation\Blender\2.74\scripts\modules\bpy\ops .py", line 189, in __call__     ret = op_call(self.idname_py(), None, kw) RuntimeError: Error: Unsupported audio format
1283
Is there a way to use the Blender Text Editor for adding a custom menu and not get a duplicate every time I click on "Run Script" to test the menu? For example, in the text editor, load the template like so:  Template -> Python -> UI Menu  Then notice every time you press "Run Script" you get another menu in your main menu bar. How can I update my menu without getting a duplicate?  I tried simply commenting out register() but then new updates don't show up.
75909
From what I've read, any changes to the environment variables in a Python instance are only available within that instance, and disappear once the instance is closed.  Is there any way to make them stick by committing them to the system?  The reason I need to do this is because at the studio where I work, tools like Maya rely heavily on environment variables to configure paths across multiple platforms.  My test code is  import os os.environ['FAKE'] = 'C:\\'   Opening another instance of Python and requesting os.environ['FAKE'] yields a KeyError.  NOTE: Portability will be an issue, but the small API I'm writing will be able to check OS version and trigger different commands if necessary.  That said, I've gone the route of using the Windows registry technique and will simply write alternative methods that will call shell scripts on other platforms as they become requirements.
105352
I want to be able to run Python commands from the Windows CMD. However, if I don't specify Python's full path for each command, I get an error saying "Python is not recognized as an internal or external command, operable program or batch file."  How do I add Python to the Windows PATH permanently?
62383
Python virtual environments are used to create isolated python environments to avoid dependency and version conflicts, and also indirectly take care of permission issues. But what is the easiest way to set it up, and use it, in Ubuntu?
44188
The path for the Python executable used in Blender (up to 2.79) is not configurable.  I looked around and did not find a consistent way to be able to use custom  3rd party Python modules without installing then directly in the O.S. Python.  This would work, although not the ideal solution, but then I had issues with that in Linux, as running pip install system wide adds the modules to /usr/local/lib, but /usr/local is not the in the PYTHONPATH when Blender is started.   An active Python virtualenv - Python's own way of isolating 3rd party modules is ignored by Blender - as the way to activate a virtualenv is simply using it's Python binary (in a different Path than the one used by Blender).
17232
Hi i'm thying threading with bpy this is my code:  import bpy import threading   class Cubes(threading.Thread):      def __init__(self):         threading.Thread.__init__(self)       def run(self):          scale = 0.2         space = 0.2         max_range = 6           for i in range(0, max_range):              bpy.ops.mesh.primitive_cube_add(radius = 1, location=(0, 0, 1))             bpy.ops.object.origin_set( type="ORIGIN_CURSOR" )              bpy.context.active_object.scale.x = scale             bpy.context.active_object.scale.y = scale             bpy.context.active_object.scale.z = 5              bpy.ops.object.transform_apply(location = False, rotation = False, scale = True)             bpy.context.active_object.location = (((i*scale*2)+(i*space))-(((max_range*scale*2)+(max_range*space)))/2,0,0)           return  t = Cubes() t.start()   but when i run this the console give me this error:  Exception in thread Thread-1: Traceback (most recent call last):   File "C:\Program Files\Blender Foundation\Blender\2.75\python\lib\threading.py", line 921, in _bootstrap_inner     self.run()   File "C:\Users\Davide\Desktop\Sound_Visualizer.blend\Sound_Visualizer_Circular.py", line 40, in run AttributeError: 'Context' object has no attribute 'active_object'   Can someone help me?
86504
Hi I would like to run a script from the terminal, is there anyway to do that? For example : if I have a python script I would normally run it with this command :    python script.py   How can I run this script just by typing in the filename of the script in the terminal (even if i'm in another directory) ?  Another answer I found pretty helpful :    You can just create symlink. Create it in /usr/local/bin. All you need is to run command:  sudo ln -s /full/path/to/your/file /usr/local/bin/name_of_new_command   After that you should make your file executable:  chmod +x /full/path/to/your/file   Now you should be able to run name_of_new_command at any time in your terminal.  Note that this is good solution only for home usage of Linux.
115975
i have this simple function in the Blender text editor : import bpy bpy.ops.object.select_pattern(pattern=&quot;Cube?&quot;) bpy.ops.object.select_pattern(pattern=&quot;Sphere?&quot;)  I just simply want to run this function using a shortcut. How can i bind a shortcut to it ? Thanks.
56205
In Linux When I invoke python from the shell it replicates its environment, and starts the python process. Therefore if I do something like the following:  import os os.environ["FOO"] = "A_Value"   When the python process returns, FOO, assuming it was undefined originally, will still be undefined. Is there a way for the python process (or any child process) to modify the environment of its parent process?  I know you typically solve this problem using something like  source script_name.sh   But this conflicts with other requirements I have.