Skip to main content
 首页 » 编程设计

python之将 Django 应用程序部署到 AWS 时出现 "ValueError: too many values to unpack"

2025年05月04日24over140

我正在尝试使用此文档将我的 Django 应用程序部署到 AWS:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html

一切顺利直到最后一步:git aws.push

它返回以下错误:

DCs-MacBook-Pro:ssite deeptichopra$ git aws.push 
Traceback (most recent call last): 
  File ".git/AWSDevTools/aws.elasticbeanstalk.push", line 41, in <module> 
    dev_tools = DevTools() 
  File "/Users/deeptichopra/Desktop/ssite/.git/AWSDevTools/aws/dev_tools.py", line 36, in __init__ 
    self.beanstalk_config = ElasticBeanstalkConfig(os.getcwd()) 
  File "/Users/deeptichopra/Desktop/ssite/.git/AWSDevTools/aws/elastic_beanstalk_config.py", line 70, in __init__ 
    self.set_credential_settings() 
  File "/Users/deeptichopra/Desktop/ssite/.git/AWSDevTools/aws/elastic_beanstalk_config.py", line 108, in set_credential_settings 
    self.credential_settings = self.credential_file["global"] 
  File "/Users/deeptichopra/Desktop/ssite/.git/AWSDevTools/aws/ini.py", line 59, in __getitem__ 
    return section.to_h() 
  File "/Users/deeptichopra/Desktop/ssite/.git/AWSDevTools/aws/ini.py", line 39, in to_h 
    (key, value) = line.split("=") 
ValueError: too many values to unpack 

mysite/.ebextensions 中的 mysite.config 文件:

container_commands: 
  01_syncdb:     
    command: “manage.py syncdb --noinput" 
    leader_only: true 
 
option_settings: 
  - namespace: aws:elasticbeanstalk:container:python 
    option_name: WSGIPath 
    value: ssite/wsgi.py 
  - option_name: DJANGO_SETTINGS_MODULE 
    value: ssite.settings 

.elasticbeanstalk 文件夹中的配置文件:

[global] 
ApplicationName=ssite 
AwsCredentialFile=/Users/deeptichopra/.elasticbeanstalk/aws_credential_file 
DevToolsEndpoint=git.elasticbeanstalk.ap-southeast-1.amazonaws.com 
EnvironmentName=ssite-env 
EnvironmentTier=WebServer::Standard::1.0 
EnvironmentType=SingleInstance 
InstanceProfileName=aws-elasticbeanstalk-ec2-role 
OptionSettingFile=/Users/deeptichopra/Desktop/ssite/.elasticbeanstalk/optionsettings.ssite-env 
RdsDeletionPolicy=Snapshot 
RdsEnabled=Yes 
RdsSourceSnapshotName= 
Region=ap-southeast-1 
ServiceEndpoint=https://elasticbeanstalk.ap-southeast-1.amazonaws.com 
SolutionStack=64bit Amazon Linux 2014.09 v1.0.9 running Python 2.7 

该应用程序在本地服务器上运行良好。有什么问题吗?

请您参考如下方法:

检查您的 ~/.elasticbeanstalk/aws_credential_file 文件。不要在这里发布内容。

是否有任何值/密码包含 =?那是你的问题。

Amazon 提供的 python 脚本在 = 上拆分了这一行,但他们并没有告诉您不能在密码中使用 = 的任何地方。