chimerax-0.1.71 python API: failed imports in module

Dear ChimeraX Team, I'm trying to use the ChimeraX API in python to automate some analysis. My code is not executing due to some missing/failed imports inside the ChimeraX module. File "/opt/anaconda3/lib/python3.11/site-packages/chimerax/core/models.py", line 54, in <module> from chimerax.graphics import Drawing, Pick, PickedTriangle ModuleNotFoundError: No module named 'chimerax.graphics' In the same file (models.py) there are also problems with this: "from .state import State" Together they are being used in the following class definition: class Model(State, Drawing): """ A Model is a :class:`.Drawing` together with an id number that allows it to be referenced in a typed command. .... """ I haven't been able to find any information on what these imports are, why they are missing, or how to resolve this issue. I also don't know if there are more missing imports, as it keeps failing here. I would appreciate your support in getting the Chimerax API to work — if this is the wrong place to ask, please do point me toward the right forum for ChimeraX. Thanks so much for the help!

You would have to show the Python script you are trying to run that produces this error for us to be able to help you. The PyPi package does not create windows and so it does not render graphics, and if your script is trying to render graphics (e.g. save an image) then that may hit an error like what you see. I've created a ChimeraX bug report to improve the PyPi ChimeraX package description to describe this limitation. https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/15647 Tom
On Jul 22, 2024, at 2:53 AM, ishaanawasthi05--- via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Dear ChimeraX Team,
I'm trying to use the ChimeraX API in python to automate some analysis. My code is not executing due to some missing/failed imports inside the ChimeraX module.
File "/opt/anaconda3/lib/python3.11/site-packages/chimerax/core/models.py", line 54, in <module> from chimerax.graphics import Drawing, Pick, PickedTriangle ModuleNotFoundError: No module named 'chimerax.graphics'
In the same file (models.py) there are also problems with this: "from .state import State"
Together they are being used in the following class definition:
class Model(State, Drawing): """ A Model is a :class:`.Drawing` together with an id number that allows it to be referenced in a typed command. .... """
I haven't been able to find any information on what these imports are, why they are missing, or how to resolve this issue. I also don't know if there are more missing imports, as it keeps failing here. I would appreciate your support in getting the Chimerax API to work — if this is the wrong place to ask, please do point me toward the right forum for ChimeraX.
Thanks so much for the help! _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/

I tested the ChimeraX 0.17.1 PyPi package (corresponding to ChimeraX 1.7.1) on Mac and I found it could not be imported (import chimerax fails) because of missing tinyarray, and once that is installed I get the error you report missing chimerax.graphics. Apparently the package was never tested. The developer who works on this is on vacation this week and will address it when he is back. I've made bug reports for these problems https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/15650 https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/15649 Tom
On Jul 22, 2024, at 10:43 AM, Tom Goddard via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
You would have to show the Python script you are trying to run that produces this error for us to be able to help you. The PyPi package does not create windows and so it does not render graphics, and if your script is trying to render graphics (e.g. save an image) then that may hit an error like what you see. I've created a ChimeraX bug report to improve the PyPi ChimeraX package description to describe this limitation.
https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/15647
Tom
On Jul 22, 2024, at 2:53 AM, ishaanawasthi05--- via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Dear ChimeraX Team,
I'm trying to use the ChimeraX API in python to automate some analysis. My code is not executing due to some missing/failed imports inside the ChimeraX module.
File "/opt/anaconda3/lib/python3.11/site-packages/chimerax/core/models.py", line 54, in <module> from chimerax.graphics import Drawing, Pick, PickedTriangle ModuleNotFoundError: No module named 'chimerax.graphics'
In the same file (models.py) there are also problems with this: "from .state import State"
Together they are being used in the following class definition:
class Model(State, Drawing): """ A Model is a :class:`.Drawing` together with an id number that allows it to be referenced in a typed command. .... """
I haven't been able to find any information on what these imports are, why they are missing, or how to resolve this issue. I also don't know if there are more missing imports, as it keeps failing here. I would appreciate your support in getting the Chimerax API to work — if this is the wrong place to ask, please do point me toward the right forum for ChimeraX.
Thanks so much for the help! _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/

Wonderful Tom, thank you so much!! Do you think the relative imports should be given bug reports as well? E.g. the "from .state import State" and the like. Once, again thank you for getting back to me so quickly, and for opening the tickets. Very much appreciated. Best, Ishaan

Hi Ishaan, I don't think more bug reports are needed. These problems seem to be in the ChimeraX 0.1.71 PyPi package but not in the ChimeraX 0.1.6 version. So you might want to uninstall the broken 0.1.71 version and install 0.1.6 python3.11 -m pip uninstall chimerax python3.11 -m pip install chimerax==0.1.6 When I try that older version the imports all work. The usual way of running scripts in ChimeraX is to just use the application, not this PyPi package. You can run them without a user interface and without windows using chimerax --nogui myscript.py The reason you might want to use the PyPi package is if you wanted to used ChimeraX with your own Python installation instead of the one that is included in the ChimeraX application. Tom
On Jul 22, 2024, at 12:45 PM, ishaanawasthi05--- via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Wonderful Tom, thank you so much!! Do you think the relative imports should be given bug reports as well? E.g. the "from .state import State" and the like.
Once, again thank you for getting back to me so quickly, and for opening the tickets. Very much appreciated.
Best, Ishaan _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/

I'll downgrade my ChimeraX PyPi version then, thank you for the heads-up! What did you mean when you described "the usual way of running scripts"? Right now I'm just using the PyPi package to automate the ChimeraX log file creation that captures a couple different metrics, then doing further processing in the python script itself. Is there a simpler way to do this? What did you mean by the Python installation included in ChimeraX application? I greatly appreciate all your insight. Best, Ishaan

Hi Ishaan, The way almost everyone uses ChimeraX is by downloading the application https://www.rbvi.ucsf.edu/chimerax/download.html The application includes Python and can work with the graphical user interface or without it. By comparision the PyPi ChimeraX package that you are trying to use is limited in that it cannot show a graphical user interface and it also has many other limitations, for instance the Python ChimeraX function "run(session, command)" to run a command is not supported in the PyPi package. Since the PyPi package does not even work people are not using it, or at least not using the current version of it. You are the first to report that it does not work and it was released March 7, 2024 about 4 months ago. Tom
On Jul 22, 2024, at 1:24 PM, ishaanawasthi05--- via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
I'll downgrade my ChimeraX PyPi version then, thank you for the heads-up!
What did you mean when you described "the usual way of running scripts"? Right now I'm just using the PyPi package to automate the ChimeraX log file creation that captures a couple different metrics, then doing further processing in the python script itself. Is there a simpler way to do this? What did you mean by the Python installation included in ChimeraX application?
I greatly appreciate all your insight.
Best, Ishaan _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/

Hi Tom, Downgrading the PyPi package worked, thank you for that fix! GUI isn't necessary for my purposes, I'm basically just measuring the differences before and after mutations are made to a structure, using ChimeraX. From there I'm further processing the scraped data using python itself. There's only one method in my python code that deals with the ChimeraX stuff. I'm thinking that the PyPi module should be enough for my basic script, but I'm new to ChimeraX so please let me know if this makes sense to you as well. Right now I was doing "from chimerax.core.commands import run" and this seemed to import fine, though I apparently didn't declare the session parameter correctly. Do you know where I can find more documentation for the PyPi package? This link —(https://pypi.org/project/ChimeraX/) — just pointed me to the recipes that you wrote and I can't find any info on run() there. Thank you! Ishaan

Hi Tom, I did just find this documentation: https://www.cgl.ucsf.edu/chimerax/docs/devel/modules/core/commands/commands.... But it doesn't include any information on how to declare the session parameter. Earlier in the documentation it says this:
"The command function arguments are expected to start with a session argument. The rest of the arguments are assembled as keyword arguments, as built from the command line and the command description. The initial session argument to a command function is not part of the command description."
Not sure how to make sense of all this. Do you have any familiarity with what I should be doing here? Thank you so much for the help, this is really clearing it up for me.

Hi Ishaan, You can import the run function but it will fail if you use it. As for examples I hunted around and found these https://github.com/RBVI/ChimeraX/tree/develop/wheel/tests I put into the bug report about improving the PyPi ChimeraX description a request for examples. https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/15647 As I mentioned before the developer who works on this is on vacation this week, so you are going to have to just try things to see if they work, or wait until he gets back. As I mentioned the usual way to run ChimeraX Python scripts is with the app. While it would be nice if you could use the PyPi package, it was intended to do what you are trying, it obviously is in poor shape with missing code and hard to find examples. Tom
On Jul 22, 2024, at 2:06 PM, ishaanawasthi05--- via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi Tom,
I did just find this documentation: https://www.cgl.ucsf.edu/chimerax/docs/devel/modules/core/commands/commands....
But it doesn't include any information on how to declare the session parameter. Earlier in the documentation it says this:
"The command function arguments are expected to start with a session argument. The rest of the arguments are assembled as keyword arguments, as built from the command line and the command description. The initial session argument to a command function is not part of the command description."
Not sure how to make sense of all this. Do you have any familiarity with what I should be doing here? Thank you so much for the help, this is really clearing it up for me. _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/

Understood — I'm grateful for all the support, Tom. I'll look into using the app directly and see what else I can do to make it work. You've been extremely helpful, I can't thank you enough! Best, Ishaan
participants (2)
-
ishaanawasthi05@gmail.com
-
Tom Goddard