How to set your PYTHONPATH 101

Yeah, I’ve done the UI preferences thing too but some scripts need the full python installation and just thought it would be worth it. I guess I’l just stick to the scripts that work until someone figures it out.

Niteowl - Thanks.

Lsystem works fine in 2.31a for me.

The JMS version works fine with 2.31a. The older one from Blender Dungeon doesn’t. 8)

Later~

linux redhat 9

‘import site’ failed; use -v for traceback

After setting my python path by altering my .bashrc and doing

import sys
print sys.path

in the blender terminal I get :

Using a clean Global Dictionary.
[’/usr/lib/python2.2/’, ‘/usr/lib/python2.2/plat-linux2’, ‘/usr/lib/python2.2/lib-tk’, ‘/usr/lib/python2.2/lib-dynload’, ‘/home/ox/blender/blender-2.31a-linux-glibc2.2.5-i386-static/blender-2.31a-linux-glibc2.2.5-i386-static’, ‘’, ‘/usr/lib/python2.2/site-packages’, ‘/usr/lib/site-python’, ‘’]

how 8) %| ?

I’m trying to set the python path on windos Me. I right clicked on my computer, went to properties and i see no advanced button.

What do you do to install python with
python 2.3 and blender 2.32??
thanks

What env. var. do u make/edit?

m@c, you must run “msconfig” and then go to the environment tab.

drago451, thats an awfully blunt question and is the topic of this entire thread. Though I do believe that blender 2.32 was designed for python 2.2.3, so use that. Blender 2.33 might have python 2.3 integration.

Thanks to Luc Peuriere for telling me about this:

To set an environment variable on Mac OSX every time you log in, you need to create a file called “evironment.plist” in a directory called “.MacOSX” in your home directory.

Here is an example:

~/.MacOSX/environment.plist


<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
    <plist version="0.9">
      <dict>
        <key>PYTHONHOME</key>
        <string>/usr/lib/python2.2</string>
      </dict>
    </plist>

http://developer.apple.com/qa/qa2001/qa1067.html

The next time you log in, PYTHONHOME should be set in the environment

However, 10.3 (Panther) comes with Python 2.3 which is not compatible with Blender. Instead, install “python22” or “python22-nox” using Fink. Blender will automatically look for the Fink-installed Python packages.

reed

PS. please send me corrections to this message if you have any.

I did this a while ago but I never posted anything about it. A few months ago I got one of those USB pendrive things and I wanted to use it to take Blender with me. Instead of just putting the installer on I tried installing directly onto the drive. It worked great and I could blend at any windows computer with USB.

After a while though I was playing around with some import/export scripts (and The Beast) and I ran into the module not found error. Luckily I already knew Python could be run from a USB drive. The problem is Blender couldn’t see it if it were the python2.2 directory… So I installed it right into the Blender directory. It works like a charm, I have blender and a full python install with me wherever I go. Now I just need to stick some statically compiled Linux binaries on there and I would be set.

BTW this will work on zip disks too

Im attempting to build from source, and am getting an error right off the bat.

I edit Sconstruct and set my sys.platform = ‘cygwin’

the I open cmd.exe change to the Blender directory and type scons

I then get the error

‘g++’ is not recognized as an internal or external command, operable program, or batch file.

my path variable includes C:\cygwin\bin

and typing g++ at the prompt and i can get help and g++ responds to other commands, etc.

I don’t think it is related to Python path, but’ I figured I’d ask to make sure.

Any ideas?

Tom M.
LetterRip

Ok, I’m trying to get my first linux blender to run with a script, in this case it’s blender 2.33, python 2.3 with the latest release of the makehuman script. I point the path to /usr/bin/python2.3 and ran the script, when I went to load a base.mesh I get this error in the plug in and in the terminal

Traceback (most recent call last):
File “Gui.py”, line 202, in draw
File “Gui.py”, line 67, in startSequence
File “Gui.py”, line 89, in makeButtons
OSError: [Errno 20] Not a directory: ‘/home/tony/download/blender-2.33a-linux-glibc2.2.5-i386/plugins/Makefile’

The plug-in directory is in /home/tony/download/blender/plugin

Anyone can tell me how to fix this ?

hi - guess i should post here rather than starting a new thread

i am trying to set the pythonpath on osx 10.3.4, blender 2.33, python 2.2 (unless 2.3 will work)

i have tried everything in this thread and the tut at the site:
http://www.blenderman.org/tutorials/python/index.html

it still can’t find the modules, i have installed the fink version of python 2.2, set the path in blender to /sw/lib/python2.2/ (i tried 2.3 beforehand). if it matters i had to install the binaries with fink as it had errors when trying to compile the source

i even set the environment variable in osx as mentioned in this thread and copied the entire python library inside the /blender.app/Content/MacOS/ directory

is there anything else to try other than reinstalling osx and doing the tut again?

any help appreciated

nay.

*** edit: this does not work properly! I will be back when I figure it all out. ***

I posted in a separate thread first, but I really feel this belongs here:

I had major problems with the Pythonpath after switching from Windows to Linux. But after a bit of help from Surphaze on irc I found out that I had to add the following to /etc/profile:



PYTHONPATH=/usr/local/lib/python2.3:/usr/local/lib/python2.3/plat-linux2:/usr/local/lib/python2.3/lib-tk:/usr/local/lib/python2.3/lib-dynload 
PYTHONHOME=/usr/local/lib/python2.3 

export PYTHONPATH 
export PYTHONHOME 
 

This is on Mandrake 9.0.

This has never been mentioned by anyone in this thread, and it is not in the manual, where it definitely should be.

Now I have to say that I start Blender from a desktop icon, not from the command line. If I had done so it would be enough to have this in my user’s bash_profile.

:slight_smile: Hans Petter

Fantastic! Thanks guys! Using the path variable installation for Windows, it installed right the first time for Win NT 4.

Thanks again!

okay, i’ve been trying to get the Tree Maker script to work for about three days now. i’m assuming the problem has to be with the path to python or i’ve got mixed versions but how to tell?

why is this so difficult? why isn’t there a line on the blender.org website that says windows users, your path is this, mac users, your path is this, linux users, your path is this? or better yet, simply include the right path for each OS in the default settings? why do we have to go scrounging through scraps on obscure websites and forums for this info when it could be easily added to blender.org?

seriously. something’s wrong here. i love the blender app, but the python documentation in the regular user manual needs some work. [/rant]

Are you using this version?

http://jmsoler.free.fr/util/blenderfile/images/lsystem/neo_lstseed228.zip

%<

yep. i’ve tried that version. i’ve also found a version written for linux that doesn’t work either. i mean, i assume there are no errors in the scripts, i just haven’t set my paths correctly or the blender script can’t locate my python install. but how to troubleshoot? it seems like this technology was written by programmers, for programmers. but as we know, programmers don’t always make the best artists, so what’s the point?

at this point i’m throwing in the towel on this python nonsense until some proper user friendly documentation is written. what a waste of time.

at this point i’m throwing in the towel on this python nonsense until some proper user friendly documentation is written. what a waste of time.

Not a healthy attitude in an opensource environment. Most everything is written by users, programmers and artists, in their spare time to better your blending experience. Your experience would most likely be better if you took the time to show us what script you are using and the error message(es) that are printed in the console. Most coders would be happy to have your feedback to debug their script. If you throw your hands up in despair after the first few tries, then what motivation do they have to continue?

I assume you’re on Linux so here is a copy and paste of the troubleshoot routine that’s posted on the first page of the Python 101 thread (for “python 2.0” read “python 2.3” or the version that you have installed):

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.3.3 (#5, Jun 21 2002, 22:51:17) 
[GCC 2.95.3 20010315 (SuSE)] on linux2 
Type "copyright", "credits" or "license" for more information. 
&gt;&gt;&gt; import sys 
&gt;&gt;&gt; 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.

%<

hi, hope this is not too easy and i don’t abuse this thread :-?

i have read this thread. now i wonder if i can also use the newest python version (2.4) with the newest blender version (2.35). i did create the PYTHONPATH (XP) but blender reports “no installed python found” in the start window. i want to use the fiber script.

thanks for any suggestion