description |
---|
How to run scripts in Python (and merge AMM deco presets) |
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?
- The Magnificent Doctor Presto's messy github repository
- manavortex's messy github repository
- Simarilius's messy github repository (for Blender)
A list of potentially useful scripts
For a folder of .mlsetup.jsons, turn layer opacity to 0 for any layer using certain microblends
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.md in the 3d editing section.
To run Python in Blender, go here.
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:
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.
- 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.
- 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
{% hint style="info" %} The link in this guide is an example script in case you don't have one. If you do, use that one instead. {% endhint %}
- Go to mana's github repo and grab the .py script to merge AMM presets:
Yes, github is scary, this is scary code. Don't worry, I gotchu.
- 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.
- Ignore the lines starting with
- Once you have everything set up, save the script.
Now it is time to run it. Keep reading!
- 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
{% hint style="info" %} The quotation marks will prevent error with spaces in path names. Leave them away at own risk :) {% endhint %}
That's it - the script will now run and do things
- 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!
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
.