Dear sir:<br><br>Thanks for the detailed reply!<br><br>When the following code was added to the start of sciprt:<br><br><i>import chimeraInit<br>chimeraInit.init(nogui=True, silent=True)</i><br><br>The interpreter print the following confused error: <br><br>---------------------------------------------<br><i>Traceback (most recent call last):<br> File "./xx.py", line 5, in <module><br> chimeraInit.init(nogui=True, silent=True)<br>TypeError: init() takes at least 1 argument (2 given)</i><br>-----------------------------------------------<br><br>it's really easy and convenient to running python script with chimera. The reason for i want to run python script independently is that i want add some custom command option. However, if i run python script with chimera, it's hard for me to add some custom command option and handle it in the script though getopt module.<br><br>For example, when i run some command like this:<br><br>chimera ¨Cnogui test.py -t test<br><br>test.py<br>################### <br>#!/usr/bin/python<br><br>t=None<br><br>try:<br> opts, args = getopt.getopt(sys.argv[1:], "t:")<br>except getopt.GetoptError, err: <br> pass<br>finally: <br> for arg_k, arg_v in opts:<br> if (arg_k =="-t"): t=arg_v<br>####################################<br><br>This will raise running exception!<br><br>is there a way for me to add the coustom option to python script and run the script with chimera?<br><br>the exception message as follow:<br><br>------------------------------------------------- <br>Executing test.py...<br><br>Traceback (most recent call last):<br> File "/home/wascm/chimera/share/chimeraInit.py", line 588, in init<br> chimera.openModels.open(a, prefixableType=1)<br> File "/home/wascm/chimera/share/chimera/__init__.py", line 1537, in open<br> models = func(filename, *args, **kw)<br> File "/home/wascm/chimera/share/chimera/__init__.py", line 972, in _openPython<br> loadFunc(sandboxName, fileName, f)<br> File "test.py", line 10, in <module><br> for arg_k, arg_v in opts:<br>NameError: name 'opts' is not defined<br>Error while processing test.py:<br>NameError: name 'opts' is not defined<br><br> File "test.py", line 10, in <module><br> for arg_k, arg_v in opts:<br><br>See reply log for Python traceback.<br><br>Traceback (most recent call last):<br> File "/home/wascm/chimera/share/chimeraInit.py", line 588, in init<br> chimera.openModels.open(a, prefixableType=1)<br> File "/home/wascm/chimera/share/chimera/__init__.py", line 1503, in open<br> raise ValueError, "Unknown model type"<br>ValueError: Unknown model type<br>Error while processing -t:<br>ValueError: Unknown model type<br><br> File "/home/wascm/chimera/share/chimera/__init__.py", line 1503, in open<br> raise ValueError, "Unknown model type"<br><br>See reply log for Python traceback.<br><br>Traceback (most recent call last):<br> File "/home/wascm/chimera/share/chimeraInit.py", line 588, in init<br> chimera.openModels.open(a, prefixableType=1)<br> File "/home/wascm/chimera/share/chimera/__init__.py", line 1503, in open<br> raise ValueError, "Unknown model type"<br>ValueError: Unknown model type<br>Error while processing test:<br>ValueError: Unknown model type<br><br> File "/home/wascm/chimera/share/chimera/__init__.py", line 1503, in open<br> raise ValueError, "Unknown model type"<br><br>See reply log for Python traceback.<br>----------------------------------------------------------<br><br><br>At 2011-03-15 09:02:09£¬"Greg Couch" <gregc@cgl.ucsf.edu> wrote:<br> <blockquote id="isReplyContent" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
(This is really a <a class="moz-txt-link-abbreviated" href="mailto:chimera-dev@cgl.ucsf.edu">chimera-dev@cgl.ucsf.edu</a> mailing list question.)<br>
<br>
My guess is that your problem is that chimeraInit.init() was never
called, so the chimera internals were never set up. So in the
beginning of your Python script, add:<br>
<br>
import chimeraInit<br>
chimeraInit.init(nogui=True, silent=True)<br>
<br>
before using chimera's modules.<br>
<br>
But, in general, you would be better off running those python
scripts with chimera. For example:<br>
<br>
% chimera --nogui --silent script.py<br>
<br>
That would set up the the appropriate environment for chimera,
execute the python script, and exit. And you would be protected
against any future changes in how chimera is initialized.<br>
<br>
If you want to use other Python modules with chimera, set your
CHIMERAPATH environment variable with a list of directories that
hold the Python modules (same syntax as PYTHONPATH, but just for
chimera).<br>
<br>
If you want to install other Python packages into chimera's Python
that have a setup.py file, use:<br>
<br>
% chimera --nogui --silent setup.py install<br>
<br>
It is also possible to make easy_install work with chimera by
temporarily putting chimera's bin directory on your path and running
the appropriate egg (see <a href="http://pypi.python.org/pypi/setuptools">http://pypi.python.org/pypi/setuptools</a>
for details). Right now, chimera is using Python 2.7.<br>
<br>
HTH,<br>
<br>
Greg<br>
<br>
</blockquote><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>