我遇到了heroku的beautifulsoup模块依赖问题。
我按照指定依赖的步骤进行了
https://devcenter.heroku.com/articles/getting-started-with-python#specify-dependencies-with-pip
但我一直收到错误“ImportError:没有名为bs4的模块” 当它到达这一行“来自bs4 import BeautifulSoup”
但requirements.txt文件包含以下内容
beautifulsoup4==4.3.2
此外,我确实从新鲜开始,并尝试制作一个新的应用程序,但没有用。 heroku服务器上的这些错误,在本地运行应用程序没有问题。
答案 0 :(得分:1)
我使用的是PhantomJS buildpack。
然而,这意味着heroku不再检测python buildpack,因此不会导入beautifulsoup。
要解决此问题,我在终端
中执行了此命令heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
然后我创建了一个名为“.buildpack”的文本文件,在开头包含点。 然后我将这两个网址粘贴到文本文件
中https://github.com/heroku/heroku-buildpack-python
https://github.com/stomita/heroku-buildpack-phantomjs
这告诉它使用python buildpack和phantomJS buildpack。