【问题标题】:Heroku not installing psycopg2 from requirements.txtHeroku 没有从 requirements.txt 安装 psycopg2
【发布时间】:2014-09-05 11:42:08
【问题描述】:

已解决

requirements.txt 中,将gunicorn==19.0.0 更改为gunicorn==18.0.0,就成功了。 19.0.0 版本与 Python 2.x 中断,它阻止 psycopg2 安装。

原始问题

我在requirements.txt 中有以下内容:

Django==1.6.5
South==0.8.4
argparse==1.2.1
dj-database-url==0.3.0
dj-static==0.0.5
django-toolbelt==0.0.1
gunicorn==19.0.0
psycopg2==2.5.2
pystache==0.5.4
static==1.0.2
wsgiref==0.1.2


但是,当我推送到 Heroku 时,它并没有安装 psycopg2,甚至没有提到任何有关此依赖项的失败。

Initializing repository, done.
Counting objects: 1257, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1213/1213), done.
Writing objects: 100% (1257/1257), 504.62 KiB | 376.00 KiB/s, done.
Total 1257 (delta 642), reused 0 (delta 0)

-----> Python app detected
-----> Installing runtime (python-2.7.8)
-----> Installing dependencies with pip
       Downloading/unpacking Django==1.6.5 (from -r requirements.txt (line 1))
       Downloading/unpacking South==0.8.4 (from -r requirements.txt (line 2))
       Downloading/unpacking argparse==1.2.1 (from -r requirements.txt (line 3))
         Running setup.py (path:/tmp/pip_build_u3159/argparse/setup.py) egg_info for package argparse

           no previously-included directories found matching 'doc/_build'
           no previously-included directories found matching 'env24'
           no previously-included directories found matching 'env25'
           no previously-included directories found matching 'env26'
           no previously-included directories found matching 'env27'
       Downloading/unpacking dj-database-url==0.3.0 (from -r requirements.txt (line 4))
         Downloading dj_database_url-0.3.0-py2.py3-none-any.whl
       Downloading/unpacking dj-static==0.0.5 (from -r requirements.txt (line 5))
         Downloading dj-static-0.0.5.tar.gz
         Running setup.py (path:/tmp/pip_build_u3159/dj-static/setup.py) egg_info for package dj-static

       Downloading/unpacking gunicorn==19.0.0 (from -r requirements.txt (line 6))
         Running setup.py (path:/tmp/pip_build_u3159/gunicorn/setup.py) egg_info for package gunicorn

       Downloading/unpacking pystache==0.5.4 (from -r requirements.txt (line 7))
         Running setup.py (path:/tmp/pip_build_u3159/pystache/setup.py) egg_info for package pystache
           pystache: using: version '5.4.1' of <module 'setuptools' from '/app/.heroku/python/lib/python2.7/site-packages/setuptools-5.4.1-py2.7.egg/setuptools/__init__.pyc'>

       Downloading/unpacking static==1.0.2 (from -r requirements.txt (line 8))
         Downloading static-1.0.2.tar.gz
         Running setup.py (path:/tmp/pip_build_u3159/static/setup.py) egg_info for package static

       Installing collected packages: Django, South, argparse, dj-database-url, dj-static, gunicorn, pystache, static
         Running setup.py install for argparse

           no previously-included directories found matching 'doc/_build'
           no previously-included directories found matching 'env24'
           no previously-included directories found matching 'env25'
           no previously-included directories found matching 'env26'
           no previously-included directories found matching 'env27'
         Running setup.py install for dj-static

         Running setup.py install for gunicorn

             File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/gaiohttp.py", line 67
               yield from self.wsgi.close()
                        ^
           SyntaxError: invalid syntax

           Installing gunicorn_paster script to /app/.heroku/python/bin
           Installing gunicorn script to /app/.heroku/python/bin
           Installing gunicorn_django script to /app/.heroku/python/bin
         Running setup.py install for pystache
           pystache: using: version '5.4.1' of <module 'setuptools' from '/app/.heroku/python/lib/python2.7/site-packages/setuptools-5.4.1-py2.7.egg/setuptools/__init__.pyc'>

           Installing pystache script to /app/.heroku/python/bin
           Installing pystache-test script to /app/.heroku/python/bin
         Running setup.py install for static

           Installing static script to /app/.heroku/python/bin
       Successfully installed Django South argparse dj-database-url dj-static gunicorn pystache static
       Cleaning up...

-----> Preparing static assets
       Collectstatic configuration error. To debug, run:
       $ heroku run python ./manage.py collectstatic --noinput

-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 34.7MB
-----> Launching... done, v5


当然,当我尝试 sync 数据库时,它会抱怨 psycopg2 未安装。
如何让 Heroku 安装缺少的依赖项?我将非常感谢任何建设性的想法。

我的数据库设置,以防对这个问题感兴趣:

DATABASES = {}
if ENV_TYPE == 'development':
    DATABASES['default'] = {'ENGINE': 'django.db.backends.sqlite3',
                            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),}
else:
    DATABASES['default'] = dj_database_url.config()

更新

报告中提到了一个SyntaxError,即gunicorn。是否可能正在阻止psycopg2 的安装?我认为不应该。

【问题讨论】:

  • yield from 在 Python 3.3 中添加。文件“/app/.heroku/python/lib/**python2.7**/site-packages/gunicorn/workers/gaiohttp.py”,第 67 行 yield from self.wsgi.close()
  • 我也注意到了,但它可能会破坏 psycopg2 吗?不是独角兽问题吗?我现在要测试它..
  • 成功了,谢谢@power。如果您将评论放入答案中,我会接受。
  • 太棒了!很高兴它对您有所帮助。
  • 我在 requirements.txt 中更改了 gunicorn 版本号,然后再次推送到 Heroku,它正确安装了 psycopg2。

标签: django heroku psycopg2


【解决方案1】:

yield from 在 Python 3.3 中添加。

File "/app/.heroku/python/lib/**python2.7**/site-packages/gunicorn/workers/gaiohttp.py"‌​, line 67 
  yield from self.wsgi.close()

【讨论】:

    猜你喜欢
    • 2017-12-05
    • 2020-09-05
    • 2021-08-06
    • 2020-07-09
    • 2019-08-27
    • 1970-01-01
    • 2020-11-26
    • 2016-03-10
    • 2021-06-28
    相关资源
    最近更新 更多