How to set your PYTHONPATH 101

Blender has its own Python app. Think of it as a Python interpretor. Some scripts though need to use more than is available in Blender. They need Python installed. Then Blender, and the script, need to know where to find Python on your HDD, it needs to know the path to python. So you ‘set the Python Path’. It’s the same as would have been done in the old windows 3.1 where you added that path to autoexec.bat.
So, no, Python doesn’t have to be open. Once, and if you have set your Python path correctly, any Python script will know where to find it.

Is Python supposed to be running when Blender is? Or how do I get these scripts to work now?

Load the script(s) into the text window, put your mouse in that window and hit ALT-P. If nothing happens look in the console window (DOS) behind Blender and see the report. If you can’t work out the problem ask in the forum and give the script, Blender version, Python version, OS and a copy of the error report.
Some scripts need a dll (so) and /or a module to be in your home (Blender) file.

%<

ok, thanks :slight_smile:

I just updatred my python path in my bash rc, and now when I open a new konsole window (or any other bash emulator) I get a flood of info

declare -x BROWSER="/usr/bin/mozilla"
declare -x COLORTERM=""
declare -x DISPLAY=":0"
declare -x GDK_USE_XFT=“1”
declare -x GDMSESSION=“XFce4”
declare -x G_BROKEN_FILENAMES=“1”
declare -x HELP_BROWSER="/usr/bin/mozilla"
declare -x HISTCONTROL=“ignoredups”
declare -x HISTSIZE=“1000”
declare -x HOME="/home/nallworth"
declare -x HOSTNAME=“dittoBox”
declare -x INPUTRC="/etc/inputrc"
declare -x KONSOLE_DCOP=“DCOPRef(konsole-3094,konsole)”
declare -x KONSOLE_DCOP_SESSION=“DCOPRef(konsole-3094,session-1)”
declare -x LANG=“en_US”
declare -x LANGUAGE=“en_US:en”
declare -x LC_ADDRESS=“en_US”
declare -x LC_COLLATE=“en_US”
declare -x LC_CTYPE=“en_US”
declare -x LC_IDENTIFICATION=“en_US”
declare -x LC_MEASUREMENT=“en_US”
declare -x LC_MESSAGES=“en_US”
declare -x LC_MONETARY=“en_US”
declare -x LC_NAME=“en_US”
declare -x LC_NUMERIC=“en_US”
declare -x LC_PAPER=“en_US”
declare -x LC_TELEPHONE=“en_US”
declare -x LC_TIME=“en_US”
declare -x LESS="-MM"
declare -x LESSKEY="/etc/.less"
declare -x LESSOPEN="|/usr/bin/lesspipe.sh %s"
declare -x LOGNAME=“nallworth”
declare -x LS_COLORS=“no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:.cmd=01;32:.exe=01;32:.com=01;32:.btm=01;32:.bat=01;32:.tar=01;31:.tgz=01;31:.tbz2=01;31:.arc=01;31:.arj=01;31:.taz=01;31:.lzh=01;31:.lha=01;31:.zip=01;31:.z=01;31:.Z=01;31:.gz=01;31:.bz2=01;31:.bz=01;31:.tz=01;31:.rpm=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;35:.xbm=01;35:.xpm=01;35:.png=01;35:.tif=01;35:.tiff=01;35:”
declare -x MAIL="/var/spool/mail/nallworth"
declare -x NLSPATH="/usr/share/locale/%l/%N"
declare -x OLDPWD
declare -x PATH="/bin:/usr/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin:/usr/bin:/usr/games:/home/nallworth/bin:/home/nallworth/bin"
declare -x PWD="/home/nallworth"
declare -x PYTHONPATH="/usr/lib/python2.2:/usr/lib/python2.2/plat-linuxi386:/usr/lib/python2.2/lib-tk:/usr/lib/python2.2/lib-dynload:/usr/lib/python2.2/site-packages"
declare -x QT_XFT=“0”
declare -x SECURE_LEVEL=“2”
declare -x SHELL="/bin/bash"
declare -x SHLVL=“2”
declare -x SSH_ASKPASS="/usr/lib/ssh/gnome-ssh-askpass"
declare -x TERM=“xterm”
declare -x USER=“nallworth”
declare -x XAUTHORITY="/home/nallworth/.Xauthority"
declare -x XA_CVMODE=“a”
declare -x XA_FACE=“ming”
declare -x XA_FAMILY=“default”
declare -x XA_MODE=“2”
declare -x XA_SMART=“1”
declare -x XMODIFIERS="@im=none"
declare -x ftp_proxy
declare -x http_proxy
$

Then it’s fine from there.

Fixified 8)

You can also use the ‘short path’ when setting an environment variable in windows.

The short path is simply this:
-if your directory name runs over 8 letters you type the first 6 letters and then add ~1 to the path (~2 if the there are more than one directory with the same first 6 letters and you want the second one).
-you should capitalize the first 6 letters
-remove any periods from directory names and make them into underscores
-ignore spaces
Example:
C:\Program Files\My Python Install\Python 22
becomes:
C:\PROGRA~1\MYPYTH~1\PYTHON~1

  1. Right click on ‘my computer’
  2. Select ‘properties’
  3. Click the ‘advanced’ tab
  4. Hit the ‘Environment variables’ button
  5. Select the ‘PATH’ variable
  6. Click the ‘Edit’ button
  7. Go to the end of the path and add a semicolon ;
  8. Add the ‘short path’ (or regular path)
  9. Restart the computer

I had Python working with Blender 2.28 in Mac OS X.2.6, but now that I’ve upgraded to Jaguar (X.3.1) I can’t get any scripts to work at all. X.3 comes with Python 2.3 installed, and I have tried everything I can think of to get things working…but they haven’t. Python launches fine from the terminal, but I just can’t get Blender scripts to run.

I’d appreciate any help. I have tried using the paths listed by sys.path in the terminal, but those still don’t work.

For Blender 2.28 & > you need Python 2.2.2 or 2.2.3

A lot of scripts were written for Blender 2.23 and Python 2.0.1 and have not yet been updated (and some .dll’s/.so’s that python may call).

%<

same problem as akator…

if anyone can help…

OK…here’s what I did that got Blender 2.28 and Python working again in Panther. I installed Jaguar onto another drive and linked the Python script path to the /usr/lib/python2.2/ directory on the Jaguar installation. It’s an ugly solution, but it give the same function that I had before the Panther upgrade.

I tried every possible solution I could think of, including installations of earlier versions of MacPython (2.2.2, 2.2.3) but those didn’t work. I have searched for other Python installations for OS X but haven’t found anything else.

Panther doesn’t use the same Python configuration, instead it uses /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/, and because the OS actually uses Python 2.3 for some functions it can’t be removed or changed without serious problems. Setting this Python path in Blender doesn’t work at all, only the Jaguar installation of 2.2 works. As I understand it, Blender just doesn’t work with Python 2.3?

Unfortunately the default Jaguar installation of Python doesn’t run well with all Blender scripts, but it does work with some. Make Human 149 works, but 150 can’t even get past “import ToEvaluate” in the first few lines (can’t figure out why it’s doing that, everything appears in order).

I’d love to hear how to get Blender and Python running as well in OS X, either Jaguar or Panther, as they apparently do with other systems. If anyone has a better solution than what I’ve done, I’d really appreciate it. There are a lot of great Blender scripts that I wasn’t able to use in Jaguar, and that means they don’t work with this extreme multi-OS-installation solution either…

I’ve assembled some of the info from here and other sites into a page about getting Python to run with Blender in OS X.

http://www.widomaker.com/~katorlegaz/blendertips/python.html

If anyone finds any errors, please let me know and I’ll correct them. Better yet, if you have any additional (or better) information I’d be happy to edit and add.

I have been able to get many Python scripts to work with Blender 2.8 and Panther by saving them as .py (Python) text files and copying them directly into the Blender package along with all of the Jaguar Python 2.2 library. The Jaguar Python 2.2 library is found in /usr/lib/python2.2/. Show contents for the Blender app and copy the scripts and library into the MacOS directory in the package. Bingo, it works…at least as well as it did in Jaguar. There is also no need to set the Python path in user settings.

I’ve been pulling my hair out trying to get Blender 2.30 to work with Python 2.2 on Mac OS X.10.2. Install 2.28 and walla! Any word on when or if 2.30 will be made functional in this regard?

you dont need to set the python path in blender for mac os x
heres how you set up python for blender 3.X and python.
install fink
install python 2.2.3 binary
this will set the python path.
blender was built on the fink instalation of python.

I’m just wondering where the autoexec.bat file is in windows 98? I’ve searched my whole comp but couldn’t find it? Thanks for any help.

Hi bender 456

the autoexec.bat is just in front of you, yes,yes
in the C:/ directory (normally) :slight_smile:
But probably it’s hiden
Set “show system or all files???” in the file property??? menu ( not sure about the names).
Bye

Hello everyone.
I’m new to Elysium and this is my first post. I’ve been using Blender for a while now (mainly for it’s modelling capabilities), but I’ve never used the Python features before but I wanted to give it a try. I’m having some trouble although. Here’s what I’ve done so far.

-Installed Python 2.2.3
-added the commandline in the autoexec.tsh file
-restarted my computer

I’m using windows98 with Norton Antivirus installed which copied and changed my autoexec file extention to .tsh. When I opened the original autoexec.bat file this is what I saw;

@C:\PROGRA~1\NORTON~1\NAVDX.EXE /Startup
@ECHO OFF
rem
rem *** DO NOT EDIT THIS FILE! ***
rem
rem This file was created by the System Configuration Utility as
rem a placeholder for your AUTOEXEC.BAT file. Your actual
rem AUTOEXEC.BAT file has been saved under the name AUTOEXEC.TSH.
rem :o

So…I added the commandline to the new TSH file, but Python isn’t working.
I looked for the Python button in the Blender2.31a User Preferences but I didn’t see it. :frowning: At this point I’m lost. I feel like I’m just overlooking something. Can anyone give me a hand?

Thanks

Thanks OTO but Niteowl just helped me figure it out. The AUTOEXEC.bat file was renamed to .ad3 so I’m going to see if i can add it to this.

BTW - I thought that was where the autoexec.bat file should’ve been but the file was renamed but norton antivirus.

Quite a coincidence that Niteowl posted after me.

Niteowl - I’ll see if mine works but might not post for a few days. (However my renamed file doesn’t have the DO NOT EDIT THIS FILE! message).

OK bender456.
I’ll fiddle with it more tonight. I’m gonna be on the road working till Christmas day but I’ll check in then.

By the way, The “DO NOT EDIT THIS FILE” message was in the New autoexec.bat file… I modified the original .bat that is now a .tsh file thanks to Norton. I still had no luck with getting Python working. :expressionless: Maybe that’s the problem…

Later~

Sorry Niteowl but I had no luck either. Strange though because when I edited my autoexec it didn’t have that message.

Is there anywhere that we can post a message to experienced python users about our problem?

I managed to get Python working by adding the Python path directly in the Blender User Preferences. I didn’t find the place to write the path at first because there was a path already assigned and I didn’t realize it was wrong…duh %|

Now my new issue is figuring out which scripts will run in 2.31. Lsystem doesn’t work. I may have to stick with 2.28 if I want to use it. :-?

As far a getting some quick help, maybe you could go to the chatbox and get some one on one.

Good luck and Merry Christmas~