# Blender: Running Python Scripts

## Summary

**Published**: Feb 08 2024 by [mana vortex](https://app.gitbook.com/u/NfZBoxGegfUqB33J9HXuCs6PVaC3 "mention")\
**Last documented edit**: Feb 08 2024 by [mana vortex](https://app.gitbook.com/u/NfZBoxGegfUqB33J9HXuCs6PVaC3 "mention")

This page will show you how to run Python scripts in Blender. It's not strictly speaking part of the Blender plugin, but I had to put this somewhere, and it's least out of place here.

## The Scripting perspective

To run scripts, you need to switch to the scripting perspective. Click the corresponding entry on the perspective toolbar at the very top:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-78cdc6c03847423dca0aa8ba5bfa04c03c06c134%2Fblender_scripting_perspective.png?alt=media" alt=""><figcaption></figcaption></figure>

The script panel looks like this:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-510c2ced655c8eb495a2ee798111f4394bd2acbc%2Fblender_script_panel_overview.png?alt=media" alt=""><figcaption></figcaption></figure>

## Running a script

1. Click on the "New Text" button to create a new document: ![](https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-767e182af3d24d736f387208f3ca81345aaf1bf0%2Fblender_new_button?alt=media)
2. Click into the `Text Editor` panel directly below it
3. **Paste** the contents of whatever script you want to run (Hotkey: `Ctrl+V`)
4. Hit the Play button above the editor panel to run the script (Hotkey: `Alt+P`)
5. **Optional:** Look at the Python Console below the 3d viewport to see feedback

## Troubleshooting

If your script doesn't work, Blender will have generated an [**exception**](#user-content-fn-1)[^1]. To look at it, toggle Blender's System Console:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-a12fea454dd23e7bea134e8c9acee1590533c169%2Fblender_show_system_console.png?alt=media" alt=""><figcaption></figcaption></figure>

Copy the contents of the console window, or pull it as big as your screen allows and take a screenshot. Give this information to the Netrunner who told you to run the script and watch as they fix it.

If you don't have a Netrunner (or if you *are* that person), this is where you hit up Google or [ChatGPT](https://rollbar.com/blog/how-to-debug-code-using-chatgpt/) (you can skip the steps 1-5 in the linked guide).

{% hint style="danger" %}
While you have text selected in the Blender System console, your Blender will be completely unresponsive.
{% endhint %}

[^1]: The technical term for "thing go brr". Give it to a Netrunner and he can use it to fix things.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.redmodding.org/cyberpunk-2077-modding/for-mod-creators-theory/3d-modelling/blender-getting-started/blender-running-python-scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
