Platform API Reference

Platform API Reference

This reference shows all methods and classes relating to App and Engine development. This is handy when you are developing your own Apps or Engines.

API Reference has moved

Please see

Tell the doc gen system that we don't want a table of contents by adding this special markup: TANK_NO_TOC



  • 0
    Genaro Rocha


    What is the best practice when developing a custom app that needs external modules? For example, I want to ssh into a server from an app, and I can do that using third party modules. Now, I am thinking I can include the packages I need with my app, by placing them in the 'python' folder as described, and using the import_module function. If this is ok, then I am running into a problem in which one module requires another module, but they can't see each other.

    For example, the package PyCrypto ( is a module that includes subpackages, and they all refer to each other. I am placing the whole Crypto package in the 'python' folder of my app and adding the import statement in python/, but when I run import_module() inside my app, I get errors regarding the subpackages not being found. like so:

    No module named Crypto.Util.py3compat
    The current environment is project.

    Code Traceback:
    File "/home/genarorg/boxel/Pipeline/tk-hiero-symlink/", line 36, in callback
    File "/home/genarorg/boxel/Pipeline/tk-hiero-symlink/", line 89, in _create_symlinks
    crypto = self.import_module("Crypto")
    File "/home/genarorg/boxel/Pipeline/jeje_staging_sandbox/install/core/python/tank/platform/", line 255, in import_module
    imp.load_module(self.__module_uid, None, python_folder, ("", "", imp.PKG_DIRECTORY) )
    File "/home/genarorg/boxel/Pipeline/tk-hiero-symlink/python/", line 12, in
    from Crypto.PublicKey import *
    File "/home/genarorg/boxel/Pipeline/tk-hiero-symlink/python/Crypto/PublicKey/", line 73, in
    from Crypto.Util.py3compat import *


    In this example, the file is trying to import from another Crypto subpackage.

    I hope this is not very confusing, its just that once a module is added, it seems that it cannot be referred to by name only.

    Any insight would be greatly appreciated, Thanks!

  • 1
    Manne Öhrström


    This is a great question and one of the limitation with our current mechanism for imports. The import_module method is used to make it easy to access, reload and handle app logic where for example two apps use two different versions of the same library. But it also has its limitations (as you have found) and this is something we are working on fixing (as part of a more longer term core initiative).

    For the time being, I would suggest adding a vendor folder (or similar) inside the app (next to the python folder) and then in the make sure that this gets added to sys.path. Then the rest of the app can just do a standard import of Crypto. Hopefully this should work nicely!

    Let me know how it goes!



Please sign in to leave a comment.