From BlenderWiki

Jump to: navigation, search
Blender3D FreeTip.gif
IMPORTANT! Do not update this page!
We have moved the Blender User Manual to a new location. Please do not update this page, as it will be locked soon.

Skriptovací jazyk Python

Python je hlavní skriptovací jazyk se speciálním rozhraním, umožňující přístup ke všem vnitřním funkcím Blenderu. Skripty jsou psány v tomto jazyce, který rozšiřuje funkcionalitu Blenderu, aniž by Blender musel být překompilován. Tyto skripty píší samotní uživatelé. Požadovaná verze Python je přiložená a nainstalovaná s distribucí, nicméně si jej můžete stáhnout a nainstalovat přímo z oficiálních stránek Python website. Pokud stahujete Python odděleně, věnujte pozornost číslu verze When downloading Python separately, do pay attention to the version number, as the two greatest version numbers will need to match the version numbers that Blender was compiled on, which is displayed in the console window when Blender starts. The supported python version for Blender as of the date for this edit is Python 2.6. Most functions do not rely on Python – a notable exception is the Help menu which opens a web browser pointed to a specific location. Help text is not bundled into Blender, you must download the latest wiki or PDF user manuals, found here or at www.blender.org.

In general, wherever you install Python, you need to establish an operating system environment variable PYTHONPATH and point it to the Blender Scripts directory where python modules are installed, e.g. C:\Program Files\Blender Foundation\Blender\scripts\bpymodules for Windows machines. Environment variables on Windows machines are set in the advanced Systems settings, in the Control Panel.

When Blender starts on a machine with Python properly installed, you will get a message in the console window, similar to this one:

 Compiled with Python version 2.6.6.
 Checking for installed Python... got it!

The above messages means that you have installed Python and have the full development and execution environment, and will be able to access, execute and run all Python scripts that are bundled or available for Blender. If you see a different message, such as:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Checking for installed Python... No installed Python found.
Only built-in modules are available. Some scripts may not run.
Continuing happily.

It just means that the full Python is not available. If you want full Python functionality, refer to the Python site for installation instructions.

When you install Blender, you must tell the Python module where you put the scripts. If you choose to put user data in a different location for each user, then the install will put your scripts in the C:\Users\<Current User>\AppData\Roaming\Blender Foundation\Blender\.blender\scripts folder. If you are upgrading, you probably want to overwrite all your old scripts with the new versions, and not have several versions of the same script hanging around on your PC. The best place, if you will not be editing them, is to put them in your Program Files folder with Blender:

  1. Do a search on your machine for a file name with the word “scripts”.
  2. You will see the scripts folder appear after the initial search: C:\Program Files\Blender-2.49\.blender\scripts, or something similar…
  3. Open the script folder from the search window. You will see all the scripts. You can leave them there, or put them on your desktop temporarily…
  4. Then go to Program Files, then to Blender Foundation, then blender folder, then make inside it a new folder called scripts
  5. Drag and drop or copy all the scripts from where ever you put them into this folder.
  6. Make sure to include the two module folders in the script one.
  7. Then, if you don’t know this already, open Blender.
  8. In Blender, the top menu bar hides all the preferences. Drag it down and then you will see a button marked File Paths.
  9. Once you click that File Paths button, a set of path fields will be revealed.
  10. Go to the Python Scripts one and type in the script folder path you just created (or use the “folder” button to open a file browser – and hit the SELECT SCRIPT PATH button to validate).
  11. Then go to the File menu and Save Default Settings (CtrlU), so that Blender will remember that the script folder is where you told it to look!
  12. Be careful though if you have already done stuff in Blender at this point, every time you start it it will be the default start up…