How to set your PYTHONPATH 101

That should have been done ages ago, but anyway…

Ok, so here’s how it will work: if you have written some piece of text on how to set the Pythonpath variable or small tricks to instal many versions of Python on the same comp, things like that, just post it here.

Please, only post meaningful and useful information.


in french but easy to translate with google’s tool:

And in this page:
look at the F/ paragraph

Python Path For Windows 2k and XP, Python20 !!

Install Python in the root of your C. i.e. C:\Python20\

Go to your start button, go up to My Computer and Right click it and go to properties.

Click on the Advanced tab, click on Environment Variables button at the bottom.

Below the System Variables box, (the second box), hit New.

In the Variable Name box, type PYTHONPATH

In the Variable Value box, type this exactly:


You can copy and paste that.

Hit OK repeatedly.


To set the Pythonpath on XP (or NT 4.0 or Win 2K):

go to the Control panel
double click System
go to the Advanced tab
click on Environement Variables

in the System Variables window
check if you have a variable named PYTHONPATH

if you have one already:
check that it points to the right directories

if you don’t have one already:
click the New button and create it

try rebooting and restarting Blender so that the internal interpreters registers the new PYTHONPATH

if that doesn’t work, there’s a fix that can be applied directly in Blender. Be aware that this will not work with script that require the use of dynamic libraries.

Open up Blender with the default scene (or use Ctrl-X to get back to it)
Pull down the Info window at the top
In the Python button at the left of the screen
Enter the path to the Lib directory in your Python distro (usually, something like c:/Python22/Lib/)
Save the user defaults with Ctrl-U


I see that I’m repeating a lot here, but here it goes anyway, you can never read this enough times :wink:

First, despite that python by now has moved on to version 2.2, Blender currently is still based on python2.01. It is possible to use higher python versions, but if you want full compatibilty, you have to install python2.01.

As of Blender version 2.26 (as well as ‘funblender’) this is no longer true, which were compiled with python2.2, so for these it is best to install python2.2, NOT python2.01.


  1. Get python2.0 from
    Direct link to the installer(might not work, you might have to use the above link instead):

To make sure that python when run from Blender can find the files it needs, you need to set a so-called ‘environment variable’ which contains all the directories python needs to be able to run properly.

    There is a shortcut to do this, which will make it possible to run most scripts, but not all of them, so it is better to set the PYTHONPATH variable, but if you don’t want to do that, you can try this. If you want to set the full pythonpath, skip ahead to part 3.
    It is possible to specify the most important python directory in Blender itself, you do that by specifying this in the user-defaults window, this window is hidden away at the top of the main Blender window.
    Drag the header downwards to find it, you can also use the windows icon, then selecting the ‘i’ icon (info-window).
    On the left side you will find a button with the name ‘Python:’, click that, and type the full path to the python lib directory, use the path to wherever you installed python, for me it would be:


followed by enter, drag the window back (otherwise Blender will always start with this window open), and use CTRL-U key (save user-defaults) and confirm by clicking or using the enterkey to save your settings.
That is all, this will be enough for most scripts.

    After installing python and restarting your computer, you will find a new menu entry in the windows ‘Start’ menu, there is an option called ‘python(commandline)’, select that, and python will start in a dos-console printing something like this on the screen:

Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.

The reason for doing this is to find out what directories to add to your PYTHONPATH variable. To do this, type ‘import sys’ followed by enter. Then ‘print sys.path’, the result should look something like this:

Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', 'c:\\python20', 'c:\\python20\\dlls', 'c:\\python20\\lib', 'c:\\python20\\lib\\plat-win',        'c:\\python20\\lib\\lib-tk', 'c:\\python20\\pil']

This is what I get, for you it might be different of course, depending on where you installed python. The important directories are the main directory, the ‘dlls’ directory, and the ‘lib’ and ‘lib-tk’ directories.
Any other ones you don’t need to add to the environment variable, but you can do that anyway if you want.
Now we need to create an environment variable that contains the same directories.
(btw, To close the python console use ‘ctrl-z’)
This will depend on what windows version you use, for Win98 for instance you have to add this variable to your autoexec.bat
Open it with notepad for instance, and add the line ‘SET PYTHONPATH=’ plus the important directories that python printed in the console window as above. So for me it would look like this:


Save it, restart your computer, and that should be it.

To set environment variable on Win2000 or WinXP, see the post by Enzoblue or theeth above.

Most if not all distributions already include a version of python, if not, you will have to compile and install it
yourself. As this is not unusual for Linux users, I won’t repeat the steps here.

  1. To find out what you have to add to your pythonpath, open a shell/terminal and start python (type python or python2.0).
    Then type ‘import sys’ followed by ‘print sys.path’, which will produce something like this:

Python 2.0.1 (#5, Jun 21 2002, 22:51:17)
[GCC 2.95.3 20010315 (SuSE)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/local/lib/python2.0', '/usr/local/lib/python2.0/plat-linux2', '/usr/local/lib/python2.0/lib-tk', '/usr/local/lib/python2.0/lib-dynload', '/usr/local/lib/python2.0/site-packages']

  1. There are now several posibilities to add the pythonpath environment variable, depending on what you use, for bash you can add this to your .bashrc file which you will find in your home directory. Open it with an editor and add the following line:

export PYTHONPATH=/usr/local/lib/python2.0:/usr/local/lib/python2.0/plat-linux2:/usr/local/lib/python2.0/lib-tk:/usr/local/lib/python2.0/lib-dynload:/usr/local/lib/python2.0/site-packages

(I’m not entirely sure about this next bit as for me it is the above)
In case you use a tcsh based shell, you need to add this to .cshrc, in which case it is slightly different:

setenv PYTHONPATH /usr/local/lib/python2.0:/usr/local/lib/python2.0/plat-linux2:/usr/local/lib/python2.0/lib-tk:/usr/local/lib/python2.0/lib-dynload:/usr/local/lib/python2.0/site-packages

I have found other references on the net that another possibility is adding it to /etc/profile.d, but I’m not a Linux expert, so I can’t say much about that.

After you set the pythonpath, log out and back in again to make it active.

For both platforms, a link that might be helpful:

I’ve tried the linux method but it doesn’t seem to work. Mac OS X.2.2, Python 2.2.1, Blender Publisher 2.2.5

For those Linux-freaks who want to put a shortcut on their KDE-/GNOME-Desktop:
Open your favourite texteditor and write down this lil script:


export PYTHONPATH=/the/import/sys/print/sys.path/listelement/from/python/go/here

Replace the paths according to your system, the Pythonpath as said above by eeshlo. Name this script as you want e.g. bstart and make it executable (chmod a+x bstart) and put it somewhere in your path e.g. /usr/local/bin (the last step should be done as root).
Now create a desktop-icon (rightclick on desktop -> new… and so on), name it blender. In the properties window for your desktop-icon under Execute -> command (this for KDE, I don’t know how this is done in GNOME, but it should work in a similar way) put bstart (maybe you need the full path for that script), switch the Run in terminal checkbox on (KDE, GNOME might be similar) and everything should work fine.
Thanks to Clawz for being the guinea pig :wink:

I dont completely understand this… What would i have to type and where, if i were to use Yable and python was installed to e:\Python\ ?

In NT-style Windows (NT, 2K, XP) you do not have to reboot to make the system environment visible to all the apps. Log off and on is enough. It bothers too, as you have to close all the running apps, but it is usually much faster then a full reboot.

You even don’t need to log off. Just restart the apps you think that they care about the variable.

how do I set my path in OS X 10.2.6? I have python already installed fomr default os X install. Where would I set the path from? Thanks

same problem…
mac osx 10.2.6…
blender 2.25, 2.27 or 2.28a…
python 2.2.3 and 2.3…

need a solution…

In the beginning of your sscripts, put this:
import sys
sys.path.extend([’’, ‘/usr/lib/python2.2’, ‘/usr/lib/python2.2/plat-darwin’, ‘/usr/lib/python2.2/lib-tk’, ‘/usr/lib/python2.2/lib-dynload’, ‘/usr/lib/pyth
that is 2 lines, first line is “import sys” and the rest is the ssecond line

I’m still meeting troubles…
an example overall:
makehuman generates an error message on import os

what can I do???
help me please…
and happy blending

I just set my path according to the instructions given above, ( the post that says to copy and paste if you like ) and I am assuming, (sorry if I sound like a total bone head here) that where it says to type in PYTHON20, I should instead type in PYTHON2.2?

Yes, of course. These were examples paths and weren’t updated for Python 2.2.3


Thanks Theeth! :smiley:

Great. I’v small question .
What’s wrong? When i’m exporting scene from povanim i get error log and script crashes:

Don’t know exactly what os ( maybe posix;) we run but we are runing icon_smile.gif
File “”, line 1097, in bevent1…
…line 899, in export_file
…line 10170, in Test_exportVers
…line6495, in writeCamera
AttributeError: ‘module’ object has no attribute ‘atan’
Error Totblck: 7
button string len: 8 0x858c39c
button string len: 8 0x858297c
button string len: 8 0x86d8fa4
button string len: 8 0x858bdc4
button string len: 8 0x858bf04
button string len: 8 0x858bf54
button string len: 384 0x8a3e43c

Other time at export script crashes because of other attribute.

What’s going on?
My python version : 2.2

I’m using blender with dedicated povanim versions, it alvays crashes.

OS: GNU/Linux

Wings works great! At the beginning i was in trouble with erlang and libesdl compilation, but now it works very stable.

ok, I am writing a version of povanim “special debian users” without math module…


um, I’m a little confused. I went and did Enzoblue’s instructions and now what do I do? Is Python supposed to be running when Blender is? Or how do I get these scripts to work now?