Running Python Scripts
How to run scripts in Python (and merge AMM deco presets)
Summary
Published: Dec 14 2023 by manavortex Last documented update: Mar 18 2024 by manavortex
This guide will teach you how to execute Python scripts under Windows.
Running Python scripts in Blender
This guide is for running files outside of Blender.
If you want to run a Python script in Blender, you need to switch your viewport to the scripting perspective and click "play".
You can find a dedicated guide on Blender: Running Python Scripts in the 3d editing section.
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FophsrSWp22qDiApSOW03%252Fblender_scripting_perspective.png%3Falt%3Dmedia%26token%3D9ae179f8-52fa-4a74-bb9e-818210ce258b&width=768&dpr=4&quality=100&sign=3ee870a0&sv=1)
Step 0: Getting Python
We start by checking if you have Python installed already.
Open a Windows command prompt (Hotkeys:
Windows+R
, typecmd
, press enter)In the window that now opens, type the following:
If you have Python installed, it will now say something like "Python 3.11.3
" . In that case, you can go directly to Step 1: Downloading the script.
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FMNe2NfbGbnoftgpPliIZ%252Fpython_version.png%3Falt%3Dmedia%26token%3Dc09e39c8-d22c-4267-9131-af60e36010ed&width=768&dpr=4&quality=100&sign=9607f7c2&sv=1)
Otherwise, please keep reading.
Close the command window - after installing Python, you need to open a new one.
Go to python.org and download the correct installer package for your system - that will usually be Windows installer (64-bit). Take the latest stable release, it will be at the very top of the page.
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FhNMNqybHyeqDh8Nt1WIp%252Fdownload_python_release.png%3Falt%3Dmedia%26token%3D913e6962-d4f5-4278-be18-9bd7c7e672b0&width=768&dpr=4&quality=100&sign=bce33cd0&sv=1)
Now, follow this guide until you have installed Python, or google something like
install python on windows for dummies
and follow that guide until you have installed Python.Proceed to Step 1: Downloading the script
Step 1: Downloading the script
The link in this guide is an example script in case you don't have one. If you do, use that one instead.
Go to mana's github repo and grab the .py script to merge AMM presets:
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FuTLYozdFsq2tAChkL65k%252Fdownload_from_github.png%3Falt%3Dmedia%26token%3D549c35fd-f124-4368-8c20-868833d9dafc&width=768&dpr=4&quality=100&sign=946a58e1&sv=1)
Download the file by clicking the corresponding button. Save it somewhere where you can find it easily.
Open the script with a text editor of your choice (we recommend Notepad++ under Windows)
Check the top of the file for anything that needs to be adjusted:
Ignore the lines starting with
import
Read the lines starting with
#
. They are comments and will tell you what to put.
Once you have everything set up, save the script.
Now it is time to run it. Keep reading!
Step 2: Run the script
Open a command window again (Hotkey: Windows+R, type
cmd
, press enter)Type
python "
(python
, space, quotation mark)Drag-and-drop the script you downloaded on the console window
Type another quotation mark and hit enter
![](https://wiki.redmodding.org/~gitbook/image?url=https%3A%2F%2F1427525421-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F4gzcGtLrr90pVjAWVdTc%252Fuploads%252FdemFEhtQ18ZwoHi9gqde%252Frun_python_script.png%3Falt%3Dmedia%26token%3Df73ebe73-a276-4e94-89a9-941d5cd6d8c4&width=768&dpr=4&quality=100&sign=851196bd&sv=1)
The quotation marks will prevent error with spaces in path names. Leave them away at own risk :)
That's it - the script will now run and do things
Troubleshooting
It complains about errors!
Step the Python version (Step 0: Getting Python, item 1 and 2). As of 2023, the version should start with a 3.
If that isn't it, you made a mistake while editing the script file. Make sure that you don't have single backslashes in strings:
If it's not that, you can use a Python syntax checker, or ask ChatGPT (I'm not kidding). Good luck!
No module named…
If you are running into this error in Blender, it should be enough to run the program as admin.
Otherwise, you are missing a Python module, and need to install it. You can do that by running the following code from your Windows cmd:
If that does not work, google for something like pip install module your_module_name windows
.
Last updated