VMD-L Mailing List
From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Fri Jul 17 2009 - 09:16:22 CDT
- Next message: Axel Kohlmeyer: "Re: File conversion for from Amber to Charmm"
- Previous message: Michael Kreim: "Re: error after changing of PYTHONPATH variable"
- In reply to: Michael Kreim: "Re: error after changing of PYTHONPATH variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
On Fri, 2009-07-17 at 15:51 +0200, Michael Kreim wrote:
[...]
> I know adding "." to a path could lead into some problems, although I
> thought that are manly security issues.
true. that is for executables, for scripts it is more an
issue of consistency. it is better to have a single consistent
location for re-usable stuff.
> 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.
that is ok. i'd suggest to just use [file normalize .] instead of '.'
and then you do have a canonical path in there and each VMD session
will be consistent with itself.
> If you or anybody else has some better ideas to manage this, I would be
> very happy to hear them.
my only suggestion is that convenience functions can usually be
very easily generalized. it takes some extra effort up front, but
in the long run, you'll be building a library of useful stuff.
i don't use much python, but tcl a lot and i have a repository
in my home directory for vmd tcl extensions that are added to the
tcl search path in .vmdrc and auto-loaded. over the time this
collection has grown and the mature scripts have found their way
into the vmd script library, plugins, or the VMD base code.
i guess if more people would do this, and particularly the many
people that seems to be using python, we would soon have a much
larger library of reusable python modules for VMD. right now it
looks to me, as if every VMD python user has to re-invent a whole
set of wheels all the time again.
cheers,
axel.
>
> 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
> >>
> >
-- ======================================================================= Axel Kohlmeyer akohlmey_at_cmm.chem.upenn.edu http://www.cmm.upenn.edu Center for Molecular Modeling -- University of Pennsylvania Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323 tel: 1-215-898-1582, fax: 1-215-573-6233, office-tel: 1-215-898-5425 ======================================================================= If you make something idiot-proof, the universe creates a better idiot.
- Next message: Axel Kohlmeyer: "Re: File conversion for from Amber to Charmm"
- Previous message: Michael Kreim: "Re: error after changing of PYTHONPATH variable"
- In reply to: Michael Kreim: "Re: error after changing of PYTHONPATH variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]