Robert Kern wrote:
<div class="moz-text-flowed" style="font-family: -moz-fixed">Jeremiah H. Savage wrote:

To use pymol and numpy together, I now do the following:

To ~/.bashrc add:
        PYMOL_PATH=/usr/lib/pymodules/python2.5/pymol
        export PYMOL_PATH

Then I can do the following in python:

     import numpy
     numpy.save('123',numpy.array([1,2,3]))
     numpy.load('123.npy')
           array([1, 2, 3])
     import sys
     sys.path.append( "/usr/lib/pymodules/python2.5/pymol")
     import pymol
     pymol.finish_launching()
     pymol.importing.load("/path/to/file.pdb")

No, do not do this. Add /usr/lib/pymodules/python2.5/ to your $PYTHONPATH, *not* /usr/lib/pymodules/python2.5/pymol/. You will continue to run into problems if you do it this way. You are not supposed to put the directory *of* the package onto sys.path but rather the directory that *contains* the package directory.

As I said before, I don't know pymol. But if that is the package name, then Robert is certainly right. You need to read the docs on pymol to see what they require. For example, it's surprising they require a separate PYMOL_PATH environment variable, since they can find their own directory path with the __file__ attribute of one of the modules.

Anyway, one more generic comment. Rather than having that directory in both the bashrc file AND in your python source, I'd consider deriving the latter from the environment variable, once you determine that it's actually necessary. And of course you could strip the last node from the path in the environment variable before appending it to sys.path, if that's what's appropriate.

DaveA




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to