# Resolve “No Module Named cx\_Oracle” Error in Dynatrace Extensions

**URL:** <https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393>\
**Category:** Extensions\
**Tags:** databases, sql, oracle, extensions\
**Created:** [November 26, 2021, 7:42pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393 "2021-11-26T19:42:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [November 26, 2021, 7:42pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/1 "2021-11-26T19:42:21Z")

</div>

_Summary: This thread explains how to resolve the “No module named cx\_Oracle” error in Dynatrace extensions. It includes installation steps and compatibility considerations for Oracle database monitoring._

Hello can anyone help me with this error? I’ve already imported the package, but I’m still getting this message.

Python

```auto
import logging
import cx_Oracle

from ruxit.api.base_plugin import RemoteBasePlugin

logger = logging.getLogger( __name__ )

```

Json

```auto
"install_requires": [
  "cx_Oracle",
  "requests>=2.6.0"
],

```

---

<div class="post-metadata">

**Author:** ![tibebe\_m\_digafe](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@tibebe\_m\_digafe](https://community.dynatrace.com/u/tibebe_m_digafe)\
**Post date:** [November 28, 2021, 2:51pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/2 "2021-11-28T14:51:04Z")

</div>

you may install the module. I just did and was able to run a plugin with the requirement.

**pip install cx\_Oracle**

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [November 29, 2021, 3:48pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/3 "2021-11-29T15:48:22Z")

</div>

I already installed this module, but the error persists.

 ![RodrigoBiaggio_1-1638195755862.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/d/dd8fadae8726af6a16751af899b735014a273817.png)

 ![RodrigoBiaggio_2-1638199395807.png](https://global.discourse-cdn.com/dynatrace/original/3X/1/6/163e34f33e6015fecc199c6d23d705501a665748.png)

It is installed.

I believe the problem is that the plugin is being built using a newer version. It’s getting cached.

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [November 29, 2021, 4:25pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/4 "2021-11-29T16:25:26Z")

</div>

To no avail the change. That wasn’t the problem with the version. It is in the same version and the problem remains.

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [November 29, 2021, 8:55pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/5 "2021-11-29T20:55:58Z")

</div>

even, from within the gateway I can run a test script and it connects to the bank, so it’s not a problem with the package. Everything is installed. I don’t understand what is missing from my script, that Dynatrace is not understanding that the module exists.

```auto
{
  "name": "custom.remote.python.integracao_interna_cc",
  "version": "1.22",
  "type": "python",
  "entity": "CUSTOM_DEVICE",
  "metricGroup": "tech.python.integracao_interna_cc",
  "technologies": [
    "Python"
  ],
  "favicon": "https://jocumpr.com.br/wp-content/uploads/2021/08/logo-pix-icone-1024.png",
  "source": {
    "package": "custom_remote_python_integracao_interna_conta",
    "className": "IntegracaoInternaCC",
    "install_requires": [
      "cx-Oracle",
      "requests>=2.6.0"
    ],
    "activation": "Remote"
  },
  "configUI": {
    "displayName": "Filas Oracle AQ - Integração Interna CC"
  },
  "ui": {
    "keymetrics": [
      {
        "key": "total_lancamentos_export_jsm",
        "aggregation": "max",
        "mergeaggregation": "sum",
        "displayname": "Integração Interna CC - Total"
      },

```

Do I need to put some lib in my plugin directory to build together?

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [November 30, 2021, 1:45pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/6 "2021-11-30T13:45:44Z")

</div>

[@tibebe\_m\_digafe](https://community.dynatrace.com/user/32618)&nbsp;, Hi. Can you help with this? You mentioned that you ran your script and it worked. Is it possible for you to share this configuration?  
Thank you

---

<div class="post-metadata">

**Author:** ![tibebe\_m\_digafe](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@tibebe\_m\_digafe](https://community.dynatrace.com/u/tibebe_m_digafe)\
**Post date:** [November 30, 2021, 3:43pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/7 "2021-11-30T15:43:57Z")

</div>

```markup
{
  "name": "custom.remote.python.oracle",
  "version": "1.0.0",
  "type": "python",
  "entity": "CUSTOM_DEVICE",
  "metricGroup": "tech.oracle",
  "technologies": ["PYTHON"],
  "install_requires": [
    "cx_Oracle",
    "requests>=2.6.0"
  ],
  "source": {
    "package": "oracle_plugin",
    "className": "Oracle",
    "activation": "Remote"
  },
  "ui" : {
    "keycharts" : [
    ],
    "charts" : [
    ]
  },
  "metrics": [
  ],
  "properties" : [
  ],
  "configUI": {
  }
}

```

---

<div class="post-metadata">

**Author:** ![tibebe\_m\_digafe](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@tibebe\_m\_digafe](https://community.dynatrace.com/u/tibebe_m_digafe)\
**Post date:** [November 30, 2021, 3:47pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/8 "2021-11-30T15:47:31Z")

</div>

using&nbsp;Python 3.6.12

installed packages

```markup
pip list
Package Version
------------------ -------------------------
attrs 21.2.0
boto3 1.18.44
botocore 1.21.44
bottle 0.12.19
certifi 2021.5.30
cffi 1.14.6
charset-normalizer 2.0.6
check-tls-certs 0.12.0
click 8.0.1
colorama 0.4.4
cryptography 3.4.8
cx-Oracle 8.3.0
idna 3.2
importlib-metadata 4.8.1
jmespath 0.10.0
jsonschema 3.2.0
pip 21.2.4
plugin-sdk 1.223.105.20210824.140926
pycparser 2.20
pyOpenSSL 20.0.1
pyrsistent 0.18.0
python-dateutil 2.8.2
requests 2.26.0
s3transfer 0.5.0
setuptools 28.8.0
six 1.16.0
typing-extensions 3.10.0.2
urllib3 1.26.6
wheel 0.29.0
zipp 3.5.0

```

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [November 30, 2021, 5:56pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/9 "2021-11-30T17:56:38Z")

</div>

Hi, can you make sure that you’re running oneagent\_build\_plugin with Python 3.6 64-bit? That way it’ll download the correct binaries.

Mike

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [November 30, 2021, 8:04pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/10 "2021-11-30T20:04:55Z")

</div>

Good afternoon people!!

I have the correct version (3.6), I also have all these libraries installed.

Also, I installed oracle client on the server.

I can connect to the database if I access python directly from the prompt, making an import in cx\_Oracle.

![RodrigoBiaggio_0-1638302537423.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/b/cbf5f88daa1b356a19a42c6bcc16adc170635620.png)

 ![RodrigoBiaggio_1-1638302599944.png](https://global.discourse-cdn.com/dynatrace/original/3X/1/e/1e05e0716686a3b3581225ec0120fedfb172c957.png)

I understand that the error is in my code.

```auto
import logging
import cx_Oracle
import os
from ruxit.api.base_plugin import RemoteBasePlugin
logger = logging.getLogger( __name__ )

class IntegracaoInternaCC(RemoteBasePlugin):

    def query(self, **kwargs):

        global con, total_lancamentos_export_jsm, state_integracao_interna_cc

        state_integracao_interna_cc = 0.0
        status_ok = "OK"
        status_notok = "Bad"
        try:
            con = cx_Oracle.connect(user="", password="", dsn="")
            cursor = con.cursor()
            print("Successfully connected to Oracle Database")
            consulta_sql = "select count(1) from cc_qcc_lanc_export_jms s where state <> 3;"
            cursor.execute(consulta_sql)
            resultado_query = (cursor.fetchall())

            for linha in resultado_query:
                total_lancamentos_export_jsm = (linha[0])
                print("Total Registros", total_lancamentos_export_jsm)

            if total_lancamentos_export_jsm == 0:
                state_integracao_interna_cc = status_ok
                print("Status:", state_integracao_interna_cc)
            else:
                state_integracao_interna_cc = status_notok
                print("Status:", state_integracao_interna_cc)

            group = self.topology_builder.create_group("Filas AQ", "Filas AQ")
            device = group.create_element("Integração Conta Corrente", "Integração Conta Corrente")
            group.report_property(key="Desenvolvedor", value="Rodrigo Biaggio")
            group.report_property(key="Secondary technology", value="Oracle")
            group.report_property(key="Integrações", value="AWS")
            group.report_property(key="Descrição", value="Filas Oracle AQ - Conta e Standin")
            device.report_property(key="Integrações", value="AWS")
            device.report_property(key="Technology", value="Python")
            device.add_endpoint(ip="", port=3306, dnsNames=[""])
            device.relative(key='total_lancamentos_export_jsm', value=total_lancamentos_export_jsm)
            group.absolute(key='total_lancamentos_export_jsm', value=total_lancamentos_export_jsm)
            device.state_metric(key='state_integracao_interna_cc', value=state_integracao_interna_cc)

        except cx_Oracle.DatabaseError as e:
            print("Erro ao acessar tabela", e)

        finally:
            con.close()
            print("Conexão ao banco encerrada")

```

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [November 30, 2021, 8:18pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/11 "2021-11-30T20:18:01Z")

</div>

What user does the plugin run as? dtuserag, dtuser?&nbsp;If the plugin is run with any of these users it can justify not finding the oracle lib.

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [November 30, 2021, 8:20pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/12 "2021-11-30T20:20:19Z")

</div>

Hi,

dtuserag. You can do a oneagent\_sim with sudo -u, that sometimes points out access issues.

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [November 30, 2021, 8:23pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/13 "2021-11-30T20:23:25Z")

</div>

It’s failing on this line:

```auto
con.close()

```

because the connection cannot be created with empty connection parameters.

You can set it to None first and then check for None before trying to close the connection.

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [December 8, 2021, 1:23am UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/14 "2021-12-08T01:23:57Z")

</div>

Hi&nbsp;[@Mike\_L](https://community.dynatrace.com/user/11520)&nbsp;[@tibebe\_m\_digafe](https://community.dynatrace.com/user/32618)

I’m still trying to get the plugin to work.

I’ve already run simulate\_plugin and it works. The problem occurs when deploying to Dynatrace.

At first, it was returning a message that the cx\_Oracle module did not exist. I redid all the installation of gateway, SDK and Oracle client. Now, even though everything works fine inside the OS, when I deploy, it returns a message that the Oracle LIB was not found.

I put in my code to return the Oracle environment variables and also the LD\_LIBRARY\_PATH and the return is none, that is, it is not finding the variable.

SIMULATE\_PLUGIN OK

 ![RodrigoBiaggio_0-1638926514937.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/4/d4ff4e1979f715e8f658292153667aac2cbe1908.png)

ERROR

 ![RodrigoBiaggio_1-1638926547613.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/c/fc7242e832f54d2a5aa2b5ebabb819b38d418bff.png)

What is causing me confusion is the fact that my user has the variables, and dtuserag is not a user with bash, it doesn’t login.

Which user does Dynatrace use, root or  
the dtuserag? These variables must be defined for which users?

Thank you

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [December 8, 2021, 9:25am UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/15 "2021-12-08T09:25:23Z")

</div>

Hi, Extensions run as dtuserag. The LD\_LIBRARY\_PATH needs to be present before the remote plugin module starts up. You can do this by adding

Environment=LD\_LIBRARY\_PATH=/path\_to\_accessible\_libraries/oracle

Inside the [Service] section of the Remote Plugin Module service script. By default it is located at /etc/systemd/system/remotepluginmodule.service

Mike

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [December 8, 2021, 12:26pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/16 "2021-12-08T12:26:34Z")

</div>

[@Mike\_L](https://community.dynatrace.com/user/11520)&nbsp;,

 ![RodrigoBiaggio_0-1638966139119.png](https://global.discourse-cdn.com/dynatrace/original/2X/2/215845bcaf352831ae7c75fdfb9d5c257b181ea3.png)

 ![RodrigoBiaggio_1-1638966268012.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/9/a9ef3ff01cdda40eb4f9fc05dd66f4e04293369e.png)

Hi, thanks for your reply.

I put all these two ways in, but it didn’t work.

I also stopped / started the process

Is that correct, is it either of these two ways?

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [December 8, 2021, 12:33pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/17 "2021-12-08T12:33:14Z")

</div>

Hi,

It’s the first one. Does the dtuserag have full access to that folder?

Mike

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [December 8, 2021, 6:13pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/18 "2021-12-08T18:13:53Z")

</div>

Yes, the user has access.

Mike, I’m stopping/starting the dynatrace service, running systemctl status dynatracegateway

Would that be enough for the module to load the path? I’m doing the restart and nothing happens. Is it possible for me to restart only the extension module?

Thank you

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [December 8, 2021, 6:20pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/19 "2021-12-08T18:20:02Z")

</div>

[@Mike\_L](https://community.dynatrace.com/user/11520)&nbsp;Or some log that I can check if it was applied or the current parameter return.

---

<div class="post-metadata">

**Author:** ![RodrigoBiaggio](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rodrigobiaggio/32/39343_2.png) [@RodrigoBiaggio](https://community.dynatrace.com/u/RodrigoBiaggio)\
**Post date:** [December 8, 2021, 6:38pm UTC](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393/20 "2021-12-08T18:38:02Z")

</div>

I did a test by changing the user from dtuserag to root. I restarted the Dynatrace service and it didn’t reflect. In my code it still points out that the plugin is running with dtuserag.

 ![RodrigoBiaggio_0-1638988660128.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/dc2f2bcc9a0e36bc8d91ee7594767d2efd959ed7.png)

 ![RodrigoBiaggio_1-1638988676885.png](https://global.discourse-cdn.com/dynatrace/original/2X/9/99da0b97dff5e1a3f43411a242234b88e994df5e.png)

[Next page](https://community.dynatrace.com/t/resolve-no-module-named-cx-oracle-error-in-dynatrace-extensions/33393.md?page=2)
