title: How to add a third party Scrapy middleware
body: <p><a href="https://i.stack.imgur.com/wFgYH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wFgYH.png" alt="enter image description here"></a></p>
  
  <p>I'm working with scrapy 1.1 . I want to add <a href="https://github.com/alecxe/scrapy-fake-useragent" rel="nofollow noreferrer"><code>scrapy-fake-user-agent</code></a> Scrapy middleware that would rotate user agents seamlessly and randomly. User Agent strings are supplied by the <a href="https://pypi.python.org/pypi/fake-useragent" rel="nofollow noreferrer"><code>fake-useragent</code> module</a>.</p>
  
  <p>following the directions from the site, I have:</p>
  
  <pre><code>DOWNLOADER_MIDDLEWARES = {
      'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
      'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware': 400,
  }
  </code></pre>
  
  <p>However when I run it I get:</p>
  
  <pre><code>ImportError: No module named scrapy_fake_useragent.middleware
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>edit: I opened a python shell in the virtualenv:</p>
  
  <pre><code>In[4]: import scrapy.downloadermiddlewares as x
  In[5]: x.useragent.UserAgentMiddleware
  Out[5]: scrapy.downloadermiddlewares.useragent.UserAgentMiddleware
  
  In[7]: import scrapy_fake_useragent as x
  In[8]: dir(x)
  Out[8]: ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
  </code></pre>
  
  <p>So 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware 'seems to be available but not 'scrapy_fake_useragent.middleware.RandomUserAgentMiddleware' ?</p>