Reputation: 31
When I have this line in my file
from prometheus_client import CollectorRegistry, pushadd_to_gateway, Info
Code runs just fine when I use 2.7 python interpreter.
However in 3.6 it gives: ImportError: cannot import name 'Info'
from prometheus_client import CollectorRegistry, pushadd_to_gateway, Info
def write_to_gateway(key, value):
registry = CollectorRegistry()
i = Info('sql_monitor_results', 'These are results of SQL queries converted into key/value info', registry=registry)
i.info({key: value})
pushadd_to_gateway('localhost:9091', job='MonitorResults', registry=registry)
if __name__ == "__main__":
write_to_gateway("xxx", "yyyy")
Upvotes: 2
Views: 2942
Reputation: 31
Thanks. It turned out I did not run pip install in virtualenv. So it acually worked from prompt but not from PyCharm. After source bin/activate and pip3 install prometheus_client it worked.
Thanks again, --vadim
Upvotes: 0
Reputation: 34152
Most likely you've an older version of the library installed for Python 3, upgrade it with pip3
.
Upvotes: 1