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.

Where do I get Python scripts?

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". Now go away, your princess is in another castle!

Step 0: Getting Python

We start by checking if you have Python installed already.

  1. Open a Windows command prompt (Hotkeys: Windows+R, type cmd, press enter)

  2. In the window that now opens, type the following:

python --version

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.

Otherwise, please keep reading.

  1. Close the command window - after installing Python, you need to open a new one.

  2. 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.

  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.

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.

  1. Go to mana's github repo and grab the .py script to merge AMM presets:

  1. Download the file by clicking the corresponding button. Save it somewhere where you can find it easily.

  2. Open the script with a text editor of your choice (we recommend Notepad++ under Windows)

  3. Check the top of the file for anything that needs to be adjusted:

    1. Ignore the lines starting with import

    2. Read the lines starting with #. They are comments and will tell you what to put.

  4. Once you have everything set up, save the script.

Now it is time to run it. Keep reading!

Step 2: Run the script

  1. Open a command window again (Hotkey: Windows+R, type cmd, press enter)

  2. Type python " (python, space, quotation mark)

  3. Drag-and-drop the script you downloaded on the console window

  4. Type another quotation mark and hit enter

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!

  1. 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:

bad  = "C:\Games\Cyberpunk 2077"
good = "C:\\Games\\Cyberpunk 2077"

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:

pip install <your_module_name>

If that does not work, google for something like pip install module your_module_name windows.

Last updated