Hi Eric,

I really appreciate your quick response. It really helps me a lot to understand it. But I have another question, following your instructions, I modified the _init_.py file but it still holds an error. I attached some related information below.

Thank you for your time and help.

Best regards,
Yongcheng

On Thu, Feb 4, 2021 at 4:09 PM Eric Pettersen <pett@cgl.ucsf.edu> wrote:
Hi Yongcheng,
You probably know this, but in order to avoid registering all commands at startup, which would involve executing the code from dozens of bundles and make startup really slow, ChimeraX uses information from the Toolshed to know which bundles implement which commands and only when the time comes to actually execute a command does it invoke the bundle's code that fully registers the command, which then allows ChimeraX to know what arguments and keywords the command allows and what function the command executes so that it can parse the command text and call that function.
So all that error text you got is indicating that there is an error in your command-registration function.  ChimeraX asks you to register your command by calling the register_command() method of your BundleAPI subclass.  Does the implementation of register_command() in your __init__.py look something like this?:

from chimerax.core.toolshed import BundleAPI

class CL_TensorFlowAPI(BundleAPI):

    @staticmethod
    def register_command(command_name, logger):
        from . import cmd
        cmd.register_command(command_name, logger)

If it does, then the problem is that you have no cmd.py file in your bundle, producing the error:

cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))

Let me know if you need further clarification.

--Eric

Eric Pettersen
UCSF Computer Graphics Lab

On Feb 4, 2021, at 10:45 AM, Yongcheng MU <ymu004@odu.edu> wrote:

Hello,

Hope you are doing well. This is Yongcheng. I am writing this email because I am trying to install a Deep learning tool in ChimeraX, but I have some issues about it.

I built and installed my code following the steps on the Chimera Guide website. I installed my code successfully, but when I run using command that I created, it hold some errors:

"RuntimeError: delayed command registration for 'CL_Tensorflow' failed (register_command() failed for command CL_Tensorflow in bundle ChimeraX-CL-Tensorflow:
cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))

File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2142, in lazy_register
raise RuntimeError("delayed command registration for %r failed (%s)" % (cmd_name, e))"

"During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/cmd_line/tool.py", line 275, in execute
    cmd.run(cmd_text)
  File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2746, in run
    self._find_command_name(final, used_aliases=_used_aliases)
  File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2489, in _find_command_name
    what.lazy_register(cmd_name)
  File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2142, in lazy_register
    raise RuntimeError("delayed command registration for %r failed (%s)" % (cmd_name, e))
RuntimeError: delayed command registration for 'CL_Tensorflow' failed (register_command() failed for command CL_Tensorflow in bundle ChimeraX-CL-Tensorflow:
cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))

RuntimeError: delayed command registration for 'CL_Tensorflow' failed (register_command() failed for command CL_Tensorflow in bundle ChimeraX-CL-Tensorflow:
cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))

File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2142, in lazy_register
raise RuntimeError("delayed command registration for %r failed (%s)" % (cmd_name, e))"

I wonder if you know what's going on here, and how to fix it. Thank you so much for your time. 

Best regards,
Yongcheng
_______________________________________________
ChimeraX-users mailing list
ChimeraX-users@cgl.ucsf.edu
Manage subscription:
https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users