2016-11-01 11 views
2

私はこの単純なpythonプログラムを作成し、メッセージをSQSに送信してから取り出します。 Python 2.7.11を使って動作します。cxフリーズする方法Boto3

from cx_Freeze import setup, Executable 

include_mods = [] 

excludes = ['tkinter', 'cltk'] 

buildOptions = dict(packages=[], excludes=excludes, includes=include_mods) 


executables = [ 
    Executable('./frozen_boto_3_test.py', 'Console') 
] 

setup(name='Boto3FrozenTest', 
    version='1', 
    description='A test to make sure boto3 is working well when frozen', 
    options=dict(build_exe=buildOptions), 
    executables=executables) 

私はこの問題に凍結されたコードに加えて

Traceback (most recent call last): 
    File "/usr/local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module> 
    exec(code, m.__dict__) 
    File "./frozen_boto_3_test.py", line 1, in <module> 
    import boto3 
    File "/usr/local/lib/python2.7/site-packages/boto3/__init__.py", line 16, in <module> 
    from boto3.session import Session 
    File "/usr/local/lib/python2.7/site-packages/boto3/session.py", line 17, in <module> 
    import botocore.session 
    File "/usr/local/lib/python2.7/site-packages/botocore/session.py", line 25, in <module> 
    import botocore.configloader 
    File "/usr/local/lib/python2.7/site-packages/botocore/configloader.py", line 18, in <module> 
    from six.moves import configparser 
    File "/usr/local/lib/python2.7/site-packages/six.py", line 203, in load_module 
    mod = mod._resolve() 
    File "/usr/local/lib/python2.7/site-packages/six.py", line 115, in _resolve 
    return _import_module(self.mod) 
    File "/usr/local/lib/python2.7/site-packages/six.py", line 82, in _import_module 
    __import__(name) 
ImportError: No module named ConfigParser 

を実行しようとすると、私はこのエラーを取得し、ライブラリー:

import boto3 
sqs = boto3.client('sqs') 
queue = sqs.get_queue_by_name(QueueName='some-que-name') 
queue.send_message(MessageBody='{"phrase": "It\'s the end of the world as we know it" }') 
for message in queue.receive_messages(): 
    print message.body 

は、私は、このスクリプトでそれをcxFreeze s3、dynamo、またはその他のサービスではないサービスを動的にロードするようです。

boto3を凍結するレシピはありますか?

+0

に掲載 'Hello Worldの' スクリプトのための作品をSQSした後は、使用して開かれています他のパッケージはフリーズする? – helloV

+0

本当にありません。あなたはどう思いますか? – jeremyvillalobos

+0

http://www.pyinstaller.org/ – helloV

答えて

2

エラーは、非表示の(動的な)インポートが行われていることを示しています。 cx_Freezeに含めるよう指示したモジュールのリストで探しているモジュール(ConfigParser)を含めると、それが機能するはずです。これを何度もやり直さなければならないかもしれません。

executables = [cx_Freeze.Executable("MyScript.py")] 
includes = ["ConfigParser"] 
buildOptions = dict(includes = includes) 
cx_Freeze.setup(name, description, options = dict(build_exe = buildOptions), 
     executables = executables) 

作業プログラムを作成したら、特定のsetup.pyを操作する代わりにこれを行うこともできます。

def load_boto3(finder, module): 
    finder.IncludeModule("ConfigParser") 

は、あなたが道に沿って発見他のものを含める:あなたはこのようになりますcx_Freeze.hooksモジュールにエントリを追加することができます。

https://bitbucket.org/anthony_tuininga/cx_freeze

0

おかげ@Anthony Tuininga

私はここに掲載していますいくつかの追加の手順がありました

追加「のConfigParser」と「HTMLParserそして、こっちプル要求や問題を作成します「アンソニーで述べたように

from cx_Freeze import setup, Executable 

include_mods = ["ConfigParser", "HTMLParser"] 

excludes = ['tkinter', 'cltk'] 

buildOptions = dict(packages=[], excludes=excludes, includes=include_mods) 


executables = [ 
    Executable('./frozen_boto_3_test.py', 'Console') 
] 

setup(name='Boto3FrozenTest', 
    version='1', 
    description='A test to make sure boto3 is working well when frozen', 
    options=dict(build_exe=buildOptions), 
    executables=executables) 

輸出AWS_DATA_PATH =は/ usr/local/lib/python2.7/DIST-パッケージ/ botocore /データ から: requests.exceptions.SSLError: [Errno 2] No such file or directory

輸出REQUESTS_CA_BUNDLE =は/ usr/local/lib/python2.7/DIST-パッケージ/ botocore/vendored /要求/ cacert.pemの

使用しSQSを使用するには、低レベルのコード:

import boto3 

sqs = boto3.client('sqs') 

queue = sqs.create_queue(QueueName="my-queue") 
sqs.send_message(QueueUrl=queue["QueueUrl"] , MessageBody='{"phrase": "It\'s the end of the world as we know it" }') 
message = sqs.receive_message(QueueUrl=queue["QueueUrl"]) 
for msg in message['Messages']: 
    print m 

SG [ 'ボディ']

これはOP

関連する問題