有人知道软件包安装顺序是否在Python中很重要?更具体地说,我正在构建的Django网站的pip requirements.txt
是:
Django==1.4
MySQL-python==1.2.3
django-evolution==0.6.7
django-pagination==1.0.7
boto==2.5.2
numpy==1.6.2
requests==0.13.1
simplejson==2.5.2
gunicorn==0.14.6
部署到Heroku时,应用程序将崩溃并出现以下错误:
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [12] [INFO] Worker exiting (pid: 12)
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [8] [INFO] Worker exiting (pid: 8)
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Handling signal: term
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [7] [INFO] Worker exiting (pid: 7)
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Starting gunicorn 0.14.6
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Listening at: http://0.0.0.0:20132 (4)
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [4] [INFO] Using worker: sync
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [7] [INFO] Booting worker with pid: 7
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [8] [INFO] Booting worker with pid: 8
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [9] [INFO] Booting worker with pid: 9
2012-08-05T09:26:56+00:00 app[web.1]: 2012-08-05 09:26:56 [10] [INFO] Booting worker with pid: 10
2012-08-05T09:26:57+00:00 heroku[web.1]: State changed from starting to up
2012-08-05T09:26:57+00:00 heroku[web.1]: Process exited with status 143
2012-08-05T09:27:17+00:00 app[web.1]: Usage: gunicorn [options]
2012-08-05T09:27:17+00:00 app[web.1]: gunicorn: error: no such option: --workers
2012-08-05T09:27:17+00:00 app[web.1]:
2012-08-05T09:27:17+00:00 app[web.1]: 2012-08-05 09:27:17 [9] [INFO] Worker exiting (pid: 9)
我的Procfile
如下:
web: python manage.py collectstatic --noinput; gunicorn commerical_production.wsgi:application --workers=4 --bind=0.0.0.0:$PORT
只需将需求顺序更改为:
即可解决问题Django==1.4
gunicorn==0.14.6
MySQL-python==1.2.3
django-evolution==0.6.7
django-pagination==1.0.7
boto==2.5.2
numpy==1.6.2
requests==0.13.1
simplejson==2.5.2
(请注意,gunicorn
现已移至顶部)
我通过猜测尝试更改导入的顺序发现了这一点,但我的问题是有其他人遇到此问题或者知道为什么从requirements.txt
安装时包的顺序有所不同?这个问题可能表明我的应用程序中出现了一些较大的依赖性问题吗?
答案 0 :(得分:1)
Pip不像easy_install那样处理包依赖关系。我们的项目遇到了同样的问题。即使req.txt中的顺序正确,我们也存在与顺序相关的依赖性问题。
我的解决方案是将req.txt提供给easy_install,但是您应该小心使用可编辑的包或来自github等的包。
您可以查看以下链接:
http://metak4ml.blogspot.com/2009/08/easyinstall-read-pip-requirementstxt.html http://community.webfaction.com/questions/1220/using-easy_install-to-get-all-dependencies-listed-in-requirementstxt(读取行答案接近我们的工作)
答案 1 :(得分:0)
Pyton安装程序安装脚本已经满足要求和订单,因此安装过程将遵守并安装,以满足需求文件中每个应用程序的所有要求。
因此,如果您有自己的应用程序需要其他人,请将您的要求仅放在您的安装文件中,并将您的主应用程序注册到requirements.txt
对于不需要编译的第三方python应用程序,您不必担心需求中的顺序。
否则eazy_install将被弃用,请使用pip代替它。