How to add python dependencies to heroku node server?

前端 未结 2 1075
情歌与酒
情歌与酒 2021-02-15 13:10

I have a Heroku app that\'s running Node, but I need to be able to run Python scripts on this server. I\'m trying to install my Python dependencies but can\'t get it to work.

2条回答
  •  执笔经年
    2021-02-15 13:55

    I've solved it so:

    1. I created (If there is not) the file "requirements.txt" directly into the root of the entrypoint (index.js, in my case)
    2. I manually added the libraries with the specific versions into the file, in my case like this:

      requests==2.7.0
      beautifulsoup4==4.5.3
      
    3. I created (If there is not) the file "runtime.txt" with with just one line: the python version i need, in my case:

      python-2.7.14
      
    4. I created the multibuildpacks with the two commands:

      heroku buildpacks:set heroku/python
      heroku buildpacks:add --index 1 heroku/nodejs
      
    5. Finally, I continued with the git commands:

      git add requirements.txt runtime.txt
      git commit requirements.txt runtime.txt -m "requirements"
      git push heroku master
      

提交回复
热议问题