title: Python and Node.js on Heroku
body: <p>I have started to make a Node server which runs on Heroku. It was working fine until I tried to use the (unofficial) Duolingo API. I wrote the following Python script to connect to the API:</p>
  
  <pre><code>import duolingo
  import simplejson as json
  
  lingo  = duolingo.Duolingo('harleyrowland')
  print json.dumps(lingo.get_user_info())
  </code></pre>
  
  <p>and my Node server uses it using the following commands:</p>
  
  <pre><code>var python = require('python-shell');
  
  module.exports = {
    getData: function(callback){
      python.run('duoScript.py', function (err, results) { 
        console.log(err);
        console.log(results);
        var res = JSON.parse(results);
        var language = res.language_data.es.language_string;
        var streak = res.language_data.es.streak;
        var level = res.language_data.es.level;
        var levelPerecentage = res.language_data.es.level_percent;
        var fluency = res.language_data.es.fluency_score;
        var nextLesson = res.language_data.es.next_lesson.skill_title;
        return callback({language, streak, level, levelPerecentage, fluency, nextLesson});
      });
    }
  }
  </code></pre>
  
  <p>which all works totally fine locally. </p>
  
  <p>When I pushed this to Heroku, the code didn't work and I started to get the following error in the Heroku logs:</p>
  
  <pre><code>{ [Error: ImportError: No module named duolingo]
       2016-10-06T00:02:32.133315+00:00 app[web.1]:   traceback: 'Traceback (most recent call last):\n  File "duoScript.py", line 1, in &lt;module&gt;\n    import duolingo\nImportError: No module named duolingo\n',
      executable: 'python',
      options: null,
      script: 'duoScript.py',
      args: null,
      exitCode: 1 
  }
  </code></pre>
  
  <p>Because of this, I went on the <a href="https://devcenter.heroku.com/articles/python-pip#the-basics" rel="noreferrer">Heroku API</a> and found that I needed to add a requirements.txt file. So I did:</p>
  
  <pre><code>duolingo-api==0.3
  simplejson==3.8.2
  </code></pre>
  
  <p>which still didn't work. I then found <a href="https://stackoverflow.com/questions/36167012/node-app-with-python-module-in-project-on-heroku-not-installing">this</a> answer and added a .buildpacks file:</p>
  
  <pre><code>https://github.com/heroku/heroku-buildpack-python.git
  https://github.com/heroku/heroku-buildpack-nodejs.git
  </code></pre>
  
  <p>and I still get the same error. </p>
  
  <p>Any idea what is causing this error?</p>
  
  <h1>Update 1</h1>
  
  <p>Thought I would show my Procfile too incase this was the problem:</p>
  
  <pre><code>web: node index.js
  pipinstall: pip install -r requirements.txt
  </code></pre>
  
  <h1>Update 2</h1>
  
  <p>Output of <code>git push heroku master</code> without <code>pipinstall</code>:</p>
  
  <pre><code>$ git push heroku master
  Counting objects: 3, done.
  Delta compression using up to 4 threads.
  Compressing objects: 100% (2/2), done.
  Writing objects: 100% (3/3), 288 bytes | 0 bytes/s, done.
  Total 3 (delta 1), reused 0 (delta 0)
  remote: Compressing source files... done.
  remote: Building source:
  remote: 
  remote: -----&gt; Node.js app detected
  remote: 
  remote: -----&gt; Creating runtime environment
  remote:        
  remote:        NPM_CONFIG_LOGLEVEL=error
  remote:        NPM_CONFIG_PRODUCTION=true
  remote:        NODE_ENV=production
  remote:        NODE_MODULES_CACHE=true
  remote: 
  remote: -----&gt; Installing binaries
  remote:        engines.node (package.json):  5.9.1
  remote:        engines.npm (package.json):   unspecified (use default)
  remote:        
  remote:        Downloading and installing node 5.9.1...
  remote:        Using default npm version: 3.7.3
  remote: 
  remote: -----&gt; Restoring cache
  remote:        Loading 2 from cacheDirectories (default):
  remote:        - node_modules
  remote:        - bower_components (not cached - skipping)
  remote: 
  remote: -----&gt; Building dependencies
  remote:        Installing node modules (package.json)
  remote: 
  remote: -----&gt; Caching build
  remote:        Clearing previous node cache
  remote:        Saving 2 cacheDirectories (default):
  remote:        - node_modules
  remote:        - bower_components (nothing to cache)
  remote: 
  remote: -----&gt; Build succeeded!
  remote:        ├── ejs@2.4.1 extraneous
  remote:        ├── emailjs@1.0.8 extraneous
  remote:        ├── express@4.13.3
  remote:        ├── http-status@0.2.3
  remote:        ├── nodemailer@1.4.0
  remote:        ├── nodemailer-smtp-transport@1.0.4
  remote:        ├── python-shell@0.4.0
  remote:        └── xoauth2@1.2.0
  remote:        
  remote: -----&gt; Discovering process types
  remote:        Procfile declares types -&gt; web
  remote: 
  remote: -----&gt; Compressing...
  remote:        Done: 13M
  remote: -----&gt; Launching...
  remote:        Released v25
  remote:        https://arcane-anchorage-33274.herokuapp.com/ deployed to Heroku
  remote: 
  remote: Verifying deploy... done.
  </code></pre>