title: Importing Stripe into Django - NameError
body: <p>I can't seem to figure out how to import Stripe into my Django project. I'm running Python 2.7.3 and I keep receiving </p>
  
  <pre><code>NameError at /complete/ global name. 'stripe' is not defined.
  </code></pre>
  
  <p>Even when I just open up Terminal and type <code>python</code> then</p>
  
  <pre><code>&gt;&gt;&gt; import stripe
  </code></pre>
  
  <p>I receive:</p>
  
  <pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ImportError: No module named stripe
  </code></pre>
  
  <p>However, if I'm in the directory:</p>
  
  <pre><code>/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
  </code></pre>
  
  <p>Then the above <code>import stripe</code> command successfully imports Stripe. However, as I've stated, Django does not know how to import Stripe. Might the issue be a path reference somewhere? I thought it might be a Python version issue, but regardless of whether I type <code>python2.6</code> or <code>python2.7</code> and then <code>import stripe</code>, it still does not work unless I'm in that directory above. Do I need to include stripe in my INSTALLED_APPS or somewhere in my project's settings.py file?</p>
  
  <p>I installed Stripe as per their documentation:</p>
  
  <pre><code> sudo pip install --index-url https://code.stripe.com --upgrade stripe
  </code></pre>
  
  <p>Which responds with: </p>
  
  <pre><code>Requirement already up-to-date: stripe in ./stripe-1.7.2-py2.7.egg
  Requirement already up-to-date: requests&gt;=0.8.8 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from stripe)
  Requirement already up-to-date: certifi&gt;=0.0.4 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from requests&gt;=0.8.8-&gt;stripe)
  Cleaning up...
  </code></pre>
  
  <p><br />
  At this point, I'm not quite sure what to do. Below is the Django traceback.</p>
  
  <p><br /></p>
  
  <pre><code>Environment:
  
  Request Method: POST
   Request URL: http://localhost:8000/complete/
  
  Django Version: 1.5.dev20120523102003
  Python Version: 2.7.3
  Installed Applications:
  ('django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'django.contrib.flatpages',
   'django.contrib.admin',
   'catalog',
   'utils',
   'cart',
   'checkout')
  Installed Middleware:
  ('django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
  
  
  Traceback:
  File "/Users/Diepenbrock/django-trunk/django/core/handlers/base.py" in get_response
    111.                         response = callback(request, *callback_args, **callback_kwargs)
  File "/Users/Diepenbrock/Documents/django_/ecomstore/checkout/views.py" in complete_order
    15.   stripe.api_key = "wXvAcOY6Rferd6oYNsc7Qi82aMm1KwyP"
  
  Exception Type: NameError at /complete/
  Exception Value: global name 'stripe' is not defined
  </code></pre>
  
  <p>EDIT: </p>
  
  <pre><code>import sys
  print sys.path
  import stripe
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>['/Users/Diepenbrock/Documents/django_/ecomstore', '/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg', '/Users/Diepenbrock/django-trunk', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']
  </code></pre>
  
  <p><br /><br /></p>
  
  <p>As per an answer, I also tried <code>pip install --index-url https://code.stripe.com --upgrade stripe</code> </p>
  
  <p><br /></p>
  
  <p>This what I received: </p>
  
  <p><br /><code>Requirement already up-to-date: stripe in ./stripe-1.7.2-py2.7.egg
  Requirement already up-to-date: requests&gt;=0.8.8 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from stripe)
  Requirement already up-to-date: certifi&gt;=0.0.4 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from requests&gt;=0.8.8-&gt;stripe)
  Cleaning up...</code></p>