Setting up PythonPath (Python Path) system variable for Windows (Blender)

Blenders System Console

Occasionally when using Python scripts with Blender they return various types of 'runtime' error, especially when performing complex operations. For the most part this is usually, and thankfully, due to Blender or a script simply trying to access Python via a "System Variable" that doesn't exist - the path to Python itself. To fix the problem it, the "PythonPath", just needs to be added to the system.

The following tutorial explains how to set up PythonPath environment variable on Windows based computers - a basic understanding of Windows based Operating Systems will be needed.

Important: the process of adding PythonPath is the same for all versions except as that relates to version numbers. In other words, whilst path structures are the same, version references are not - "Python27", "Python32" and so on, instead of "Python22" as exampled below.

The Python system variable (pythonpath) ^

As briefly mentioned in the introduction to fix Blender not being able to find Python a 'path' reference needs to be added to Windows so the application and other programs can then find the Python API installation. This is done through the inclusion of a "System Variable", commonly called the "PythonPath". Essentially the variable is a collection file locations, details to different key components and modules of the API, for example a typical PythonPath might appear similar to the following when the Python API has been installed to "C:\Python22\";

C:\PYTHON22;C:\PYTHON22\DLLs;C:\PYTHON22\LIB;C:\PYTHON22\LIB\LIB-TK

Its also sometimes written using double backslashes but either should work;

C:\\PYTHON22;C:\\PYTHON22\DLLs;C:\\PYTHON22\LIB;C:\\PYTHON22\LIB\\LIB-TK

As can be seen in the above examples the installation folder for the Python API software is the 'root' location from which other module paths are referenced, separated by semi-colons.

Design note: the actual path will vary depending upon Python installation location and whether any version numbers are used - typically because more than one iteration of the software might be in place.

PythonPath, System Properties & Windows 7 ^

Most System Variables, PythonPath included, are added via "System Properties". To access this right-click the Desktop icon titled "Computer" and select "Properties" from the context menu. This opens the main "System" window.

Design note: if "Computer" is not on the Desktop click "Start" (button bottom-left or Taskbar) and right-click the entry on the right-hand side of the menu (also titled "Computer"), select "Properties". Alternatively open "Control Panel" ("Start » Control Panel (on the right)" or "Start » All Programs » Accessories » System Tools » Control Panel") and select "System and Security" then "System".

With "System" now open, upper-left should be a text link titled "Advanced system settings". left-click this to open "System Properties". A dialogue/settings window will appear pre selected to "Advanced" properties (active).

Design note: accessing "System Properties" requires a 'User' account (the account used to log into the computer after booting) with 'Administrative Privileges' - indicated by the shield icon - without the appropriate rights, clicking "Advanced system settings" will result in a warning and blocked or password protected access.

Accessing "System Properties" by clicking "Advanced system settings"

Windows 7 "System" (System Information) from where "System Properties" can be accessed by clicking the "Advanced system settings" link on the left - the dialogue will open with "Advanced" options active

Accessing Environment Variables ^

With "System Properties" open on "Advanced" (if not click the tab marked "Advanced"), click the button at the bottom of the page named "Environment Variables...". A new window appears titled "Environment Variables" showing a list of entries across two sections, some with commands, others with system, program or file paths. This is where the PythonPath will eventually display once added.

Design note: the upper section contains data pertinent to the current user logged in to the computer - "User variables for [user profile]" will be personalised with [user profile] being the 'name' of the user account logged in to the PC. The lower "System variables" section contains data for the system itself.

"Environment Variable" from where the new PythonPath will be added

Once "System Properties" is open click the "Environment Variables" button bottom of the "Advanced" page of options - a second dialogue window will appear displaying two blocks of data; "User variables for [user profile]" and "System Variables"

Adding a new system variable ^

With "Environment Variables" open, to add the PythonPath a new "System Variable" has to be created. In the lower "System variables" section click "New". The "New System Variable" dialogue box will appear showing two empty text input fields; "Variable name:" and "Variable value:".

In "Variable name:" type (all one word, no spaces, not specifically case-sensitive);

  • PythonPath

And in "Variable value:" type (no spaces or gaps, not specifically case-sensitive);

  • C:\PYTHON22;C:\PYTHON22\DLLs;C:\PYTHON22\LIB;C:\PYTHON22\LIB\LIB-TK

Design note: the path used will differ from the above for two reasons; 1) the version of Python installed differs, meaning path references may read as "PYTHON35" or just "PYTHON" and so on, depending upon the location of installation (rather than it being "PYTHON22" as shown - the number typically correlates to the Python API version where more than one iteration is installed). And 2) in reference to #1 above, depending on the installation location, paths may need to be truncated down to the eight characters associated with old style 'DOS' commands. In other words;

  • C:\Program File (x86)\Python35\

Becomes/is truncated to;

  • C:\Progra~1\Python35\

If Blender still reports it's unable to find Python after the addition of PythonPath, checking the above should be first port of call for errors (notwithstanding typos or other 'human' input issues).

The "New System Variable" dialogue

From the "System variables" section of "Environment Variables" click "New" to create a new entry

Adding the PythonPath data to the "New System Variable" input fields

In both text input fields, "Variable name:" and "Variable value:" add the appropriate data (type or copy/paste) - "PythonPath" and the installation relative file and module paths details

Saving PythonPath variable ^

Once the variable name and value have been added, to save the information just click "OK". This will close the "New System Variable" dialogue and return back to "Environment Variables" displaying the new addition in the lower "System variables" preview pane. Click "OK" to close "Environment Variables" and "OK" again to close "System Properties" and finish the process.

Design note: although not specifically required, rebooting the computer once the PythonPath has been added will check the addition have been done correctly.

PythonPath displayed in "System variables"

Once the variable information has been added to the new entry click "OK" to 'save' and close the dialogue - the new details will display as a listing in the "System variables" section. Then "OK" the "Environment Variables" and "System Properties" dialogue boxes to complete the process

PythonPath & Windows 10 ^

Although PythonPath is essentially in the same location for Windows 10 as it is, and has been for most versions of Windows Operating System, getting to the correct location to add, edit, remove variables involves a few more steps than previously when being accessed from the Desktop as a 'normal' user.

Design note: there are similarly a number of ways to get to the Environment Variables properties window (see note below).

To do this click the "Action Center" icon bottom-right of the Taskbar. This opens a panel. Click "All settings", then "System" in the "Settings" window that appears. In "System" click "About", then the "System Info" link bottom the the right hand page (scroll down where necessary) to open the now familiar "System" page that contains all details about the computer Windows 10 is operating on. To the left, click the bottom link "Advanced system settings" to access the similarly familiar dialogue box, already open on "Advanced" settings. Click "Environment Variables..." bottom the the page to access the standard "Environment Variables" properties box where options can be added, edited or removed.

Design note: a shorter route is to click the "Start" button bottom-left, selecting "Settings" from the lower section of the list. From there click "System" etc., as above. This just removes the first couple of steps associated with starting from the desktop as was possible using previous versions of Windows. Alternatively, again from the "Start" menu, click "All apps", scroll down to "Windows System", right-click "This PC" and select "Properties" to access the appropriate "Advanced system settings" link.

An even more direct alternative to is to type "Env" into the Start menu "Search" box, this opens the "Environment Variable" dialogue window directly, bypassing all the intermediary steps to otherwise normal access.

From the Desktop click the "Action Center" icon in the Taskbar

From Windows 10 Desktop, click the "Action Center" icon bottom-right in the Task-Bar...

"Action Center" where "All settings" is found

... then in the panel that appears, click "All settings"...

"Settings" where "System" info is accessed

... which opens another windows. Click "System" ...

"System" settings where "About » System Info" is accessed

... which accesses yet another window. On the left click "About" then scroll down to the bottom of the right side where the "System Info" link appears. Click it ...

"System Information" where "Advanced system settings" is accessed

... which opens the now standard "System" window for Windows OS where all the pertinent information about the computer being used is located. On the left click "Advanced system settings" ...

"System Properties" dialogue where "Environment Variables..." is accessed

... which opens the now standard "System Properties" dialog on the "Advanced" page where the "Environment Variables..." button appears. Click that to access the dialogue and add, edit, remove entries as required (add PythonPath information as described above)

Video outlining how to access WIndows 10 Environment Variable dialogue to input PythonPath

Adding PythonPath to Windows 8 ^

Adding PythonPath to Windows 8 based computers is exactly the same as the above with one or two initial differences accessing the "System" information page. From the "Desktop", if the "This PC" icon is available, right-click and select "Properties" from the context menu then continue as outlined above. Or, from the "Desktop" again, access the Desktop Sidebar by moving the mouse cursor to screen top-right, click "Settings" when the Sidebar appears then "PC Info" on the following ("Settings") page. The "System" window will then appear on the Desktop allowing the procedure outlined above to be continued as normal from that point on.

Design note: to access "System" from Windows 8 Start Screen find the "Control Panel" tile/icon and click to open, Windows will switch to the Desktop with Control Panel open, scroll down and select "System" from the list of icons. If neither Control Panel nor Desktop tiles are on the Start screen click the 'down arrow' bottom left to access "Apps", "Desktop" should be listed under "D". Alternatively click the magnifying glass icon top-left of Start screen and type "control panel" - Windows Search will present a number of options whilst typing, or display search results on pressing "Enter" (or automatically open Control Panel on the Desktop - assuming the term was typed correctly).

Selecting "Settings" from Windows 8 Sidebar

Accessing "System" from Windows 8 Desktop by clicking on "Settings" in the Sidebar (accessed by moving the mouse top-right of the screen)

Selecting "PC info" from the Sidebar in Windows 8

In the Sidebar again ("Settings") click "PC info" to open "System"

"System" window in Windows 8

The "System" Window open in Windows 8, clicking "Advanced system settings" will open "System Properties" to enable the addition of a 'PythonPath' new system variable

Adding PythonPath to Windows XP ^

Adding PythonPath to Windows XP based machines is much the same as described above with exception again to how "System Properties" is accessed. From the Desktop simply right-click "My Computer" (icon) and select "Properties" from the list of options, "System Properties" will appears defaulting to "General" properties. Click the tab titled "Advanced", then on the "Environment Variables" button bottom of that page. A new dialogue will appear called "Environment Variables". Below the lower "System variables" section click "New" to add the PythonPath data to a new entry using the "New System Variable" dialogue as outlined above. Once done click "OK" to close all dialogues back to the Desktop (and reboot if prompted, or to ensure proper uptake).

Design note: as with newer versions of Windows, "System Properties" can be accessed a number of ways; from "Start » Control Panel » System"; from "Start" right-click "My Computer".

Important: as of April 2014 Microsoft no longer supports Windows XP.

Adding PythonPath to Windows XP

For Windows XP, right-click the "My Computer" Desktop icon (if available) to access "System Properties" through the "Environment Variables" to be able to set new "PythonPath" entry in place

Python Path and Windows Vista ^

To add PythonPath to Windows Vista, if the "Computer" icon is available on the Desktop, right-click and select "Properties", the "System" information window will appear. Continue as above. Alternatively, click "Start" and select "Control Panel" on the right or from "(Start ») All Programs » Accessories » System Tools". On the page that appears select "System and Maintenance" then "System" on the following page. Continue the procedure as per the above for Windows 7.

Design note: Windows XP, Windows Vista, Windows 7 and Windows 8 all use the same procedure when adding variables once System Properties is accessible.

Add Python Path environment system variable to Windows Vista

Add Python Path environment system variable to Windows Vista

Blender users - which version of Python to install ^

Because the Python API is constantly being improved updates are not necessarily backward compatible. This can be problematic for Blender so it's always best practice to, at the very least, use a version of Python matching what Blender was compiled against.

Design note: although Python is generally forward compatible the preference is to version match, for Blender 2..45 for example, this would mean using Python 2.5 - this ensures the application can access and use modules and features that might otherwise have been moved or omitted from later versions.

Checking which Python version should be used can be done inspecting Blenders "System Console", a Command Prompt window that often (but not always) appears when Blender starts, displaying various 'status' messages, including whether Blender has been able to find Python or not, or confirming the correct version is available.

Design note: so long as a given version of Python is installed to its respective folder or directory it's possible to install several instances of the API to cater to specific versions of Blender (which can also be similarly installed).

To find or access Blenders System Console simply start the application. For any version below Blender 2.49 the console will be available in Windows Taskbar as an additional 'Blender' instance. Simply click the Taskbar button associated with the console to reveal it. For Blender 2.50 and above (up to and including current releases), System Console can be similarly revealed by selecting the appropriate Taskbar button. In instances where neither the System Console nor a Taskbar button is visible it means the console has been hidden (toggled 'off') by default and will need to be displayed from within Blender. Once Blender is open, from the main application menu-header click "Window » Toggle System Console" to toggle the console 'on' (shown).

Design note: for versions of Blender 2.50 and above (up to, and including, current releases), the consoles visibility on starting is inconsistent and random - it may be shown by default in one version but hidden in the next without any obvious reasons as to why there is a difference in application preference.

Blender command prompt console

Blenders "System Console" is a 'command prompt' window, accessed from "Window » Toggle System Console" when not visible in newer versions of Blender (display default - whether its visible - depends on the version of Blender being used, some show it by default when Blender starts, others do not)

With the System Console visible, inspecting the text will indicate the version of Python Blender is using or needs to be installed. On starting Blender 2.45 for example a System Console messages informs Blender was compiled against Python 2.5, meaning when PythonPath is added to the system all path data will likely need to be set is relevant to "C:\Python25\" (default installation assumed). Similarly starting Blender 2.49 the Console indicates Python 2.6.2, so again PythonPath may be relative to "C:\Python26\". However, for newer versions of Blender, 2.50 and above (up to, and including, current releases), the Console points out that Blender bundles the necessary Python files it uses negating, for the most part, the need to install Python or set-up PythonPath.

Design note: the installation of Python discussed in this tutorial is relative to its use with Blender; when developing Python applications or scripts for other software or products Python will still need to be installed and PythonPath set up as per the above.

Blender 2.45 requires Python 2.5 to be installed

Blender 2.45 requires Python 2.5 to be installed

Blender 2.49 requires Python 2.6.2

Blender 2.49 requires Python 2.6.2

Blender can use it's own internal Python modules

Blender 2.5 and above (up to and including current versions) bundles necessary Python files it needs, installing them alongside the main application - this may or may not mean the set up of PythonPath being unnecessary depending upon requirements

^