drno-reg
@drno-reg
см не кратко

Как решить проблему ImportError: cannot import name 'start_http_server' from 'prometheus_client'?

Здравствуйте.

Попробовал написать клиент для prometheus

#!/usr/local/bin/python
# coding: utf-8
# import sys
# from pprint import pprint as p
# p(sys.path)

from prometheus_client import start_http_server, Summary
import random
import time

# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')

# Decorate function with metric.
@REQUEST_TIME.time()
def process_request(t):
    """A dummy function that takes some time."""
    time.sleep(t)

if __name__ == '__main__':

    # Start up the server to expose the metrics.
    start_http_server(8000)
    # Generate some requests.
    while True:
        process_request(random.random())


OS Windows 8.1
Python 3.7.0a2

'C:\Python37\python37.zip',
'C:\Python37\DLLs',
'C:\Python37\lib',
'C:\Python37',
'C:\Python37\lib\site-packages'

Collecting prometheus_client
Using cached prometheus_client-0.1.0.tar.gz
Installing collected packages: prometheus-client
Running setup.py install for prometheus-client ... done
Successfully installed prometheus-client-0.1.0

возвращается ошибка

Traceback (most recent call last):
  File "C:/Server/Repositories/Projects/um_open/templates/Test/prometheus_client.py", line 10, in <module>
    from prometheus_client import start_http_server, Summary
  File "C:\Server\Repositories\Projects\um_open\templates\Test\prometheus_client.py", line 10, in <module>
    from prometheus_client import start_http_server, Summary
ImportError: cannot import name 'start_http_server' from 'prometheus_client' (C:\Server\Repositories\Projects\um_open\templates\Test\prometheus_client.py)


Что не так и как ее решить?
  • Вопрос задан
  • 511 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы