当前位置: 首页 > 知识库问答 >
问题:

弹性豆茎上的psycopg2-无法部署应用程序

苍兴怀
2023-03-14

我正在将我的第一个应用程序(Flask)部署到EB,遇到了一个障碍。使用PostgreSQL需要安装psycopg2,但我不知道如何让它运行。

我在这篇文章(Amazon Elastic Beanstalk上的Psycopg2)和这篇文章中都看到了(https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/)我需要添加一个文件名。elasticbeanstalk/01_包装。使用以下代码配置

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,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 (Executor::NonZeroExitStatus)

很明显,我需要安装psycopg2,但我不确定我还可以采取哪些其他步骤来实现这一点。

共有1个答案

屠盛
2023-03-14

我解决了,你需要先打开你的EC2实例,然后像这样安装

sudo yum install postgresql-devel

然后部署您的EB

 类似资料:
  • 我有一个用Python 2.7/Tornado编写的服务器,我正在尝试将其部署到AWS上。我遇到了AWS弹性豆茎,它看起来是一种非常方便的方法来部署我的代码。 txt文件中有一个tornado==4.4.2的条目。 我尝试添加一些日志语句来写入外部文件,但该文件没有被创建,这可能意味着应用程序甚至没有启动。 如果有人能提供一些在AWS-EB上部署龙卷风应用程序的步骤,或者我应该如何开始解决这个问题

  • 我试图在AWS Elastic Beanstek上部署一个geodjango应用程序。配置是64位AmazonLinux2017.09 v2.6.6运行Python 3.6。尝试部署时我收到此错误: 如何安装所需的软件包?我通读了在AWS Beanstalk或EC2实例中使用GeoDjango支持设置Django,但是我仍然遇到问题。我的ebextensions目前看起来像:

  • 我对Amazazon Web服务提供的弹性IP服务的使用有点困惑。我想主要的想法是,按照以下简单的过程,我可以切换到web应用程序的新版本,而不会停机: null 抱歉,如果有些问题听起来很愚蠢,但我只是一个程序员,这是我第一次建立云系统。 谢谢!

  • 假设我在Wordpress中创建了一个站点,它运行在Elastic Beanstalk上。现在,在运行的应用程序上,我将创建帖子/页面,上传图像等。也就是说,数据库中的一些数据、视频、文件和记录将被添加到运行的应用程序中。 从我在AWS控制台中看到的情况来看,我可以部署一个应用程序的不同版本--但是根据上面的场景,如果我部署了一个新版本,我会不会丢失直接上传到正在运行的应用程序中的所有文件(即文件

  • 我正在严格遵循弹性豆茎文档(http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html),但我无法使用git部署节点.js或PHP应用程序。 如果我试图从git推动,也会发生同样的事情 当您调用eb init时,AWS工具会设置一些git快捷方式。失败的呼叫是。。。 该python模

  • 我的Flask应用程序需要包cryptography==2.2.2。我在requirements.txt中包含了这一点。 但是当部署到AWS上时,我得到了一个错误 对于那些感兴趣的人,我使用的是运行在64位debian/2.10.0上的Python 3.4。后来我将配置切换到运行在64位Amazon Linux/2.7.0上的Python 3.6,似乎解决了这个问题。 我现在的问题是我得到了这个错