加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 弹性beanstalk上的psycopg2 – 无法部署应用程序

发布时间:2020-12-16 23:34:59 所属栏目:Python 来源:网络整理
导读:我正在将我的第一个应用程序(Flask)部署到EB,并且遇到了麻烦.使用PostgreSQL需要我安装psycopg2,但我无法弄清楚如何让它运行. 我在这篇文章(Psycopg2 on Amazon Elastic Beanstalk)以及这篇文章(https://realpython.com/blog/python/deploying-a-django-app-
我正在将我的第一个应用程序(Flask)部署到EB,并且遇到了麻烦.使用PostgreSQL需要我安装psycopg2,但我无法弄清楚如何让它运行.

我在这篇文章(Psycopg2 on Amazon Elastic Beanstalk)以及这篇文章(https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/)中看到,我需要使用以下代码添加文件名.elasticbeanstalk / 01_packages.config:

packages:
  yum:
    postgresql-devel: []

我用postgresql93-devel尝试了不同的变化:[]但仍然没有运气.下面附有我的错误日志.

[2015-11-16T21:03:24.749Z] INFO  [2680]  - [Application update/AppDeployStage0/AppDeployPreHook/03deploy.py] : Starting activity...
[2015-11-16T21:03:27.024Z] INFO  [2680]  - [Application update/AppDeployStage0/AppDeployPreHook/03deploy.py] : Activity execution failed,because: Collecting psycopg2==2.6.1 (from -r /opt/python/ondeck/app/requirements.txt (line 1))
    Using cached psycopg2-2.6.1.tar.gz
      Complete output from command python setup.py egg_info:
      running egg_info
      creating pip-egg-info/psycopg2.egg-info
      writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
      writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
      writing pip-egg-info/psycopg2.egg-info/PKG-INFO
      writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
      warning: manifest_maker: standard file '-c' not found

      Error: pg_config executable not found.

      Please add the directory containing pg_config to the PATH
      or specify the full executable path with the option:

          python setup.py build_ext --pg-config /path/to/pg_config build ...

      or with the pg_config option in 'setup.cfg'.

      ----------------------------------------
  Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-z20gvx7_/psycopg2
  2015-11-16 21:03:27,010 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py",line 22,in main
      install_dependencies()
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py",line 18,in install_dependencies
      check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV,'bin','pip'),requirements_file),shell=True)
    File "/usr/lib64/python2.7/subprocess.py",line 540,in check_call
      raise CalledProcessError(retcode,cmd)
  CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError)
caused by: Collecting psycopg2==2.6.1 (from -r /opt/python/ondeck/app/requirements.txt (line 1))
    Using cached psycopg2-2.6.1.tar.gz
      Complete output from command python setup.py egg_info:
      running egg_info
      creating pip-egg-info/psycopg2.egg-info
      writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
      writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
      writing pip-egg-info/psycopg2.egg-info/PKG-INFO
      writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
      warning: manifest_maker: standard file '-c' not found

      Error: pg_config executable not found.

      Please add the directory containing pg_config to the PATH
      or specify the full executable path with the option:

          python setup.py build_ext --pg-config /path/to/pg_config build ...

      or with the pg_config option in 'setup.cfg'.

      ----------------------------------------
  Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-z20gvx7_/psycopg2
  2015-11-16 21:03:27,cmd)
  CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

似乎很清楚我需要安装psycopg2,但我不确定我可以采取哪些其他步骤来使其工作.

解决方法

我解决了,你需要先打开你的EC2实例,然后像这样安装
sudo yum install postgresql-devel

然后部署您的EB

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读