2016-11-01 3 views
2

나는이 간단한 파이썬 프로그램을 작성하여 SQS에 메시지를 보낸 다음이를 검색합니다. 파이썬 2.7.11을 사용하여 작동합니다.cx Freeze 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

을 사용하여 열고 있습니까 동결하는 다른 패키지? – 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/지방/LIB/python2.7/DIST-패키지/botocore/데이터 01,235,에서 : requests.exceptions.SSLError: [Errno 2] No such file or directory

수출 REQUESTS_CA_BUNDLE =/usr/지방/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 [ '몸'이 SQS는 영업 이익에 게시 된 '안녕하세요'스크립트 작동 후