cannot add or apply the user defined package of TCL in Python
Question: I have a TCL script that requires a user defined package within, when I run
the TCL through python by the below script:

    
    
    import subprocess
    p = subprocess.Popen(
        "tclsh tcltest.tcl",
        shell=True,
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()
    print stdout
    print stderr
    

returns the following error:

    
    
    can't find package __teapot__
    
        while executing
    
    "package require __teapot__"
    

the TCL works in tclsh environment! I believe that something is wrong in my
setup that python doesn't recognize the package!


Answer: I wonder if the environment variables are not passed in explicitly. How about:

    
    
    import subprocess
    import os
    p = subprocess.Popen(
        "tclsh tcltest.tcl",
        env=os.environ,
        shell=True,
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()
    print stdout
    print stderr
    

### Update

Since that does not make any different, stick the following line into the
first line of _tcltest.tcl_ file and compare the outputs:

    
    
    puts ">>$auto_path<<"
    

I suspect the `auto_path` variable is different between the two cases. This
variable is one way Tcl uses to locate packages.

