From: Michael Kreim (mkreim_at_keychem.de)
Date: Fri Jul 17 2009 - 08:51:46 CDT

Thanks a lot Axel.

> set env(PYTHONPATH) "$env(PYTHONPATH):[file normalize .]"

This solved my problem.

> ouch!! setting a "path" to the current working directory
> is almost always a bad idea. the behavior of programs will
> be very inconsistent, depending where you choose your
> current working directory.

I know adding "." to a path could lead into some problems, although I
thought that are manly security issues.
I am doing this to write some small analysis scripts for vmd using
python. Normally I split my scripts into several files for keeping an
overview. These files are only useful for this particular script and I
want to include them via "import MyHelpingFunctions". Maybe this is not
a very pythonic way to code but I like it.

If you or anybody else has some better ideas to manage this, I would be
very happy to hear them.

With best regards,

Michael

Axel Kohlmeyer wrote:
> On Fri, 2009-07-17 at 14:12 +0200, Michael Kreim wrote:
>> Hello,
>
> hello michael!
>
>> I have some trouble setting my PYTHONPATH environmental variable in vmd
>> 1.8.6.
>> When I set:
>>
>> set env(PYTHONPATH) .
>
> ouch!! setting a "path" to the current working directory
> is almost always a bad idea. the behavior of programs will
> be very inconsistent, depending where you choose your
> current working directory.
>
>> I always get this error:
>> $ vmd -dispdev text -python
>> Info) VMD for LINUXAMD64, version 1.8.6 (April 6, 2007)
>> Info) http://www.ks.uiuc.edu/Research/vmd/
>> Info) Email questions and bug reports to vmd_at_ks.uiuc.edu
>> Info) Please include this reference in published work using VMD:
>> Info) Humphrey, W., Dalke, A. and Schulten, K., `VMD - Visual
>> Info) Molecular Dynamics', J. Molec. Graphics 1996, 14.1, 33-38.
>> Info) -------------------------------------------------------------
>> Info) Multithreading available, 4 CPUs detected.
>> Info) Free system memory: 2290MB (58%)
>> /home/mkreim/data/bin/python/python-2.2.3/
>> .
>> Info) Starting Python...
>> Traceback (most recent call last):
>> File "<string>", line 1, in ?
>> ImportError: No module named VMD
>> Info) Text interpreter now Python
>> But when I print my path using python (sys.path) the actual directory is
>> included.
>>
>> If I don't set PYTHONPATH everything starts up without errors, but I
>> cannot load own modules.
>
> please note that PYTHONPATH is a "path", i.e. it may already contain
> multiple entries, e.g. those added by VMD. if you plain set it, you
> will delete all previous entries. so what you'd have to do is something
> like this:
>
> set env(PYTHONPATH) "$env(PYTHONPATH):[file normalize .]"
>
> that will append your current directory in a canonical form
> to and existing path. since VMD appends its own directories
> to PYTHONPATH, you can rely on it being set from within .vmdrc.
>
>> Unfortunately I did not find anything helpful regarding this problem. So
>> maybe somebody can give me some hint?
>
> this is not a VMD problem at all, so you may have looked in
> the wrong place. i hope my suggestions help.
>
> cheers,
> axel.
>
>> Thanks in advance.
>>
>> With best regards,
>>
>> Michael
>>
>