question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'start_http_server' from 'prometheus_client' (Python 3.7.0a2)

See original GitHub issue

Hello,

OS Windows 8.1 Python 3.7.0a2

tryed to excute code

#!/usr/local/bin/python
# coding: utf-8

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())

returned error

Traceback (most recent call last):
  File "C:/Server/Repositories/Projects/um_open/templates/Test/prometheus_client.py", line 4, in <module>
    from prometheus_client import start_http_server, Summary
  File "C:\Server\Repositories\Projects\um_open\templates\Test\prometheus_client.py", line 4, 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)

How solve this problem?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
drno-regcommented, Dec 21, 2017

I understood where was mistake, name my python app same with name file in module prometheus_client

0reactions
drno-regcommented, Dec 20, 2017

returned after executed python script

import sys from pprint import pprint as p p(sys.path)

Read more comments on GitHub >

github_iconTop Results From Across the Web

prometheus_client ImportError: cannot import name 'Info'
Code runs just fine when I use 2.7 python interpreter. However in 3.6 it gives: ImportError: cannot import name 'Info'
Read more >
Prometheus_client can be used on OS windows and python ...
Hello, try to wrote prometheus_client took simple code, #!/usr/local/bin/python # coding: utf-8 from prometheus_client import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found