title: ImportError: No module named 'prometheus.client'
body: <p>I am currently trying to run a <a href="https://github.com/slok/prometheus-python/blob/master/examples/memory_cpu_usage_example.py" rel="nofollow noreferrer">sample code</a> I code off of the internet. </p>
  
  <p>While trying to run it using python2.7, I get the following ERROR :</p>
  
  <pre><code># python2.7 example.py 
  Traceback (most recent call last):
    File "example.py", line 9, in &lt;module&gt;
      from http.server import HTTPServer
  ImportError: No module named http.server
  </code></pre>
  
  <p>I tried to run the following :</p>
  
  <pre><code># pip install http.server
  Collecting http.server
    Could not find a version that satisfies the requirement http.server (from versions: )
  No matching distribution found for http.server
  </code></pre>
  
  <p>But when I use python3, it does not give me the ERROR. Rather gives the ERROR :</p>
  
  <pre><code># python3 example.py 
  Traceback (most recent call last):
    File "example.py", line 13, in &lt;module&gt;
      from prometheus.client import Gauge
  ImportError: No module named 'prometheus.client'
  </code></pre>
  
  <p>Im trying to install <code>prometheus.client</code> using pip and pip3 but nothing.</p>
  
  <pre><code># pip install prometheus.collectors
  Collecting prometheus.collectors
    Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
  No matching distribution found for prometheus.collectors
  
  # pip3 install prometheus.collectors
  Collecting prometheus.collectors
    Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
  No matching distribution found for prometheus.collectors
  </code></pre>
  
  <p>How can I get the missing libraries ? </p>
  
  <p><strong>EDIT ::</strong></p>
  
  <p>In the below example I am using a very minimalist approach (again from github)</p>
  
  <pre><code>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())
  </code></pre>
  
  <p>Running the above code yields :</p>
  
  <pre><code># python3.4 main.yaml 
  Traceback (most recent call last):
    File "main.yaml", line 1, in &lt;module&gt;
      from prometheus_client import start_http_server, Summary
  ImportError: No module named 'prometheus_client'
  </code></pre>
  
  <p>Whereas I do have the library installed. </p>
  
  <pre><code># pip3 install prometheus_client
  Requirement already satisfied: prometheus_client in /usr/lib/python2.7/site-packages
  </code></pre>