Hints, tips and tutorials for 3D modelling & content creation
|
KatsBits
Creating 3D models, meshes &
game content
3D modelling & meshing, level editing and textures makingHints, tips and tutorials for 3D modelling & content creation [back]Setting up the Python Path system variableContents
What is Python? ^Although most scripts that run from Blender - either included when you install the application or 3rd party scripts created or downloaded - don't necessarily need the Python API to be installed you may, during the course of using Blender 3D, find that a number of the more 'complex' Python *.py scripts don't run reporting various 'runtime' errors. This, thankfully, is usually to do with the script trying to access a Python 'variable' that's either not included with Blender or with the script being run, and if the script doesn't have any other syntax errors, is usually easy to fix by installing the full Python API and setting up Python's 'system variable'. The tutorial below walks through the simple steps to setting Windows XP systems. It's basically a programming language that has a long history that forms part of a computer system Operating Environment; Microsoft's 'Windows' environment is a notable exception which is why it often needs to be installed. Linux and Mac OS users shouldn't need to install Python. The Python 'system variable' (python 'path')? ^Basically we need to set a 'system variable' for Windows so it, and programs that use Python, know where to look for the files and modules installed. The Python variable is a collection of 'file paths' to various 'module' locations within the API root directory; for the sake of simplicity the example shown below are the path sections associated with an installation of Python to C:\Python22; C:\PYTHON22;C:\PYTHON22\DLLs;C:\PYTHON22\LIB;C:\PYTHON22\LIB\LIB-TK It's also sometimes written as follows; C:\\PYTHON22;C:\\PYTHON22\DLLs;C:\\PYTHON22\LIB;C:\\PYTHON22\LIB\\LIB-TK But either method should work. How to set up the Python pathIf you find that you need to set up the Python system variable then the following information will tell you how to do it System Properties ^If you have the 'My Computer' icon on your desktop right click on that and select 'Properties', this should open the following dialogue box displaying the 'General' page by default. Find the tab at the top of the window called 'Advanced' and click to select that page. On this page at the bottom is a button saying 'Environment Variable', click that button.
![]() The 'Advanced' page in 'System Properties' dialogue Environment Variables ^The window that opens when clicking the 'Environment Variables' button in the Advanced tab lists a number of variables - their names and 'values' (usually a file path) - installed by other applications; you normally don't need to be in this part of Windows; this is a notable exception. This dialogue is split into two sections; the upper part are 'User' variables to do with the current logged on user; the lower half being 'System' or 'system wide' variables that apply to everyone/thing using the computer. It's here that we need to create a 'new' variable. ![]() Current system variables installed by other applications Creating a new variable ^In the lower half click on the 'New' button to open the 'Add/Edit' input dialogue. ![]() Creating a new system variable Enter the following details, which may vary depending on where you have Python installed;
'System Variable' details entered ^Once you add in the details you should end up with something similar to the image below which shows the new variable 'name'; 'PYTHONPATH' and it's 'value'; "C:\PYTHON22; etc...". ![]() The new variable 'name' and 'value' Once this is done you can 'OK' the procedure which will return you to the initial 'Environment Variables' dialogue window. You should now see, in the lower section, a new item listed (you may need to scroll the window depending on what else is listed) similar to that shown below. Once you see this you can 'OK' this window to return back to the main 'System Properties' dialogue window. If at this point (or some point in the future) you see an error in the variable information either double click or select it and hit 'Edit' to amend the entry. 'OK' once you're done. ![]() The new variable in place Python path and other Operating Systems? ^Basically yes. If you're running Windows XP (Home or Pro) you shouldn't need to restart your computer; Windows 95/98/ME/2000 users, on the other hand may need to reboot to set the variable in place. Once all this is complete you should find that, baring any code errors, scripts will now run correctly.
|