title: Python3 ImportError: cannot import name 'cookies' from 'http'
body: <p>This seems to be a very common, possibly involving a conflict between Python 2.x and Python 3.x libraries. For instance, this answer suggests the problem is with the path:</p>
  
  <p><a href="https://stackoverflow.com/questions/20078774/import-python-module-fails-http-cookies?rq=1">Import Python module fails (http.cookies)</a></p>
  
  <p>but the full error that I get is: </p>
  
  <pre><code>ImportError: cannot import name 'cookies' from 'http' (/usr/local/lib/python3.7/site-packages/gunicorn/http/__init__.py)
  </code></pre>
  
  <p>and if I do this: </p>
  
  <pre><code>cat /usr/local/lib/python3.7/site-packages/gunicorn/http/__init__.py
  </code></pre>
  
  <p>I see: </p>
  
  <pre><code># -*- coding: utf-8 -
  #
  # This file is part of gunicorn released under the MIT license.
  # See the NOTICE for more information.
  
  from gunicorn.http.message import Message, Request
  from gunicorn.http.parser import RequestParser
  
  __all__ = ['Message', 'Request', 'RequestParser']
  </code></pre>
  
  <p>So clearly, for the version of <code>HTTP</code> that I have, there is no <code>cookies</code> module exported. </p>
  
  <p>If I do this:</p>
  
  <pre><code>find /usr/local/lib64/python3.7/site-packages/   -name  cookie.py
  </code></pre>
  
  <p>I see two entries: </p>
  
  <pre><code>/usr/local/lib64/python3.7/site-packages/django/contrib/messages/storage/cookie.py
  
  /usr/local/lib64/python3.7/site-packages/django/http/cookie.py
  </code></pre>
  
  <p>This file: </p>
  
  <pre><code>/usr/local/lib64/python3.7/site-packages/django/http/cookie.py
  </code></pre>
  
  <p>starts with:</p>
  
  <pre><code>from http import cookies
  </code></pre>
  
  <p>Does it make sense that this can import from itself from <code>http</code>, when it lives in <code>http</code>? And <code>http</code> does not export this in its <code>__init__.py</code> file? </p>
  
  <p>UPDATE:</p>
  
  <p>If I run this:</p>
  
  <pre><code>/usr/local/lib/python3.7/site-packages/gunicorn/gunicorn    ecommerce.wsgi:application --bind 0.0.0.0:8000
  </code></pre>
  
  <p>This is the full stacktrace that I see:</p>
  
  <pre><code>[2018-08-19 21:19:15 +0000] [14987] [INFO] Starting gunicorn 19.9.0
  [2018-08-19 21:19:15 +0000] [14987] [INFO] Listening at: http://0.0.0.0:8000 (14987)
  [2018-08-19 21:19:15 +0000] [14987] [INFO] Using worker: sync
  [2018-08-19 21:19:15 +0000] [14990] [INFO] Booting worker with pid: 14990
  [2018-08-19 21:19:15 +0000] [14990] [ERROR] Exception in worker process
  Traceback (most recent call last):
    File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
      worker.init_process()
    File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
      self.load_wsgi()
    File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
      self.wsgi = self.app.wsgi()
    File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
      self.callable = self.load()
    File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
      return self.load_wsgiapp()
    File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
      return util.import_app(self.app_uri)
    File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
      __import__(module)
    File "/usr/share/lynette-ecomerce-demo/ecommerce-site/version1/django/ecommerce/wsgi.py", line 12, in &lt;module&gt;
      from django.core.wsgi import get_wsgi_application
    File "/usr/local/lib64/python3.7/site-packages/django/core/wsgi.py", line 2, in &lt;module&gt;
      from django.core.handlers.wsgi import WSGIHandler
    File "/usr/local/lib64/python3.7/site-packages/django/core/handlers/wsgi.py", line 8, in &lt;module&gt;
      from django.core.handlers import base
    File "/usr/local/lib64/python3.7/site-packages/django/core/handlers/base.py", line 7, in &lt;module&gt;
      from django.urls import get_resolver, set_urlconf
    File "/usr/local/lib64/python3.7/site-packages/django/urls/__init__.py", line 1, in &lt;module&gt;
      from .base import (
    File "/usr/local/lib64/python3.7/site-packages/django/urls/base.py", line 8, in &lt;module&gt;
      from .exceptions import NoReverseMatch, Resolver404
    File "/usr/local/lib64/python3.7/site-packages/django/urls/exceptions.py", line 1, in &lt;module&gt;
      from django.http import Http404
    File "/usr/local/lib64/python3.7/site-packages/django/http/__init__.py", line 1, in &lt;module&gt;
      from django.http.cookie import SimpleCookie, parse_cookie
    File "/usr/local/lib64/python3.7/site-packages/django/http/cookie.py", line 1, in &lt;module&gt;
      from http import cookies
  ImportError: cannot import name 'cookies' from 'http' (/usr/local/lib/python3.7/site-packages/gunicorn/http/__init__.py)
  [2018-08-19 21:19:15 +0000] [14990] [INFO] Worker exiting (pid: 14990)
  [2018-08-19 21:19:15 +0000] [14987] [INFO] Shutting down: Master
  [2018-08-19 21:19:15 +0000] [14987] [INFO] Reason: Worker failed to boot.                                                            
  </code></pre>
  
  <p>This is a file that I created based on a different Stackoverflow answer: </p>
  
  <pre><code>/usr/local/lib/python3.7/site-packages/gunicorn/gunicorn 
  </code></pre>
  
  <p>The contents of this file are:</p>
  
  <pre><code>#!/usr/bin/python3
  
  #-*- coding: utf-8 -*-
  import re
  import sys
  
  from gunicorn.app.wsgiapp import run
  
  
  if __name__ == '__main__':
          sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$','',sys.argv[0])
          sys.exit(run())    
  </code></pre>
  
  <p>If I do this: </p>
  
  <pre><code>find /usr/local/lib/python3.7/   -name cookies.py
  </code></pre>
  
  <p>I see: </p>
  
  <pre><code>/usr/local/lib/python3.7/site-packages/cookies.py
  /usr/local/lib/python3.7/site-packages/future/backports/http/cookies.py
  /usr/local/lib/python3.7/site-packages/future/moves/http/cookies.py
  /usr/local/lib/python3.7/site-packages/requests/cookies.py
  </code></pre>
  
  <p>If I print out sys.path:</p>
  
  <pre><code>for p in sys.path:
      print(p)
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>/usr/local/lib/python3.7/site-packages/gunicorn
  /usr/local/lib64/python3.7/site-packages
  /usr/lib64/python37.zip
  /usr/lib64/python3.7
  /usr/lib64/python3.7/lib-dynload
  /usr/local/lib/python3.7/site-packages
  /usr/lib64/python3.7/site-packages
  /usr/lib/python3.7/site-packages
  /usr/local/lib/python3.7/site-packages/gunicorn/..
  /usr/local/lib/python3.7/site-packages/gunicorn/../project                                    
  </code></pre>