# Python API: Importing QIIME2 plugins

**URL:** <https://forum.qiime2.org/t/python-api-importing-qiime2-plugins/3096>\
**Category:** Developer Discussion\
**Tags:** artifact-api\
**Created:** [February 19, 2018, 4:46pm UTC](https://forum.qiime2.org/t/python-api-importing-qiime2-plugins/3096 "2018-02-19T16:46:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomasz](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/dbc845/32.png) [@tomasz](https://forum.qiime2.org/u/tomasz)\
**Post date:** [February 19, 2018, 4:46pm UTC](https://forum.qiime2.org/t/python-api-importing-qiime2-plugins/3096/1 "2018-02-19T16:46:38Z")

</div>

Hi!

Why do I have to import each of `qiime2.plugins` separately? If I do `import qiime2`, I must follow it with (e.g.) `from qiime2.plugins import diversity`. Why doesn't `qiime2.plugins.diversity` work after importing  
all of qiime2?

thanks,  
Tomasz

---

<div class="post-metadata">

**Author:** ![jairideout](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jairideout/32/9_2.png) [@jairideout](https://forum.qiime2.org/u/jairideout)\
**Post date:** [February 19, 2018, 5:57pm UTC](https://forum.qiime2.org/t/python-api-importing-qiime2-plugins/3096/3 "2018-02-19T17:57:32Z")

</div>

Hi @tomasz, great question! The `qiime2.plugins` import path is dynamically generated based on the currently installed plugins, and it can take awhile to generate this API because each plugin must be imported via its respective Python entry point (this is accomplished by `qiime2.sdk.PluginManager`). We intentionally avoided recursive imports in this manner so that running `import qiime2` can be speedy.

Importing all plugins via the `PluginManager` can be so slow that the QIIME 2 command line interface (`q2cli`) does quite a bit of work to cache plugin info to disk in order to avoid importing plugins each time a command (or tab completion) is executed.

---

<div class="post-metadata">

**Author:** ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)\
**Post date:** [March 22, 2018, 11:57pm UTC](https://forum.qiime2.org/t/python-api-importing-qiime2-plugins/3096/5 "2018-03-22T23:57:42Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
