繁体   English   中英

是否有将jaeger 4.0.0与pyinstaller(python3.7)一起使用的解决方法?

[英]Is there a workaround for using jaeger 4.0.0 with pyinstaller(python3.7)?

不幸的是,我不能与jaeger一起使用PyInstaller。 问题是PyInstaller和jaeger之间存在某种节俭错误。 喜欢在这里讨论。

他们有任何解决方法或修补程序吗?

我已经尝试使用python 3.6和最新的jaeger-client。 在那里,我得到了Errno 2->即使我什至不使用配置文件

  exec(bytecode, module.__dict__)
  File "jaeger/__init__.py", line 17, in <module>
  File "jaeger/core/configuration.py", line 74, in get_config
FileNotFoundError: [Errno 2] No such file or directory: '/Users/.../PycharmProjects/untitled1/dist/app/jaeger/core/../etc/jaeger.yml'

[6348] Failed to execute script app
from quart import Quart
import uvicorn as uv
import logging
import time
from jaeger_client import Config

app = Quart(__name__)


@app.route('/')
async def root():
    return 'Hello world'

if __name__ == '__main__':
    log_level = logging.DEBUG
    logging.getLogger('').handlers = []
    logging.basicConfig(format='%(asctime)s %(message)s', level=log_level)

    config = Config(
        config={  # usually read from some yaml config
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'logging': True,
        },
        service_name='your-app-name',
        validate=True,
    )
    # this call also sets opentracing.tracer
    tracer = config.initialize_tracer()

    with tracer.start_span('TestSpan') as span:
        span.log_kv({'event': 'test message', 'life': 42})

        with tracer.start_span('ChildSpan', child_of=span) as child_span:
            span.log_kv({'event': 'down below'})

    time.sleep(
        2)  # yield to IOLoop to flush the spans - https://github.com/jaegertracing/jaeger-client-python/issues/50
    tracer.close()  # flush any buffered spans
    uv.run(app)


该脚本按预期运行->创建跨度并启动Web服务器。 仅在可执行文件中,它不会运行。 并显示以下错误:

  exec(bytecode, module.__dict__)
  File "jaeger/__init__.py", line 17, in <module>
  File "jaeger/core/configuration.py", line 74, in get_config
FileNotFoundError: [Errno 2] No such file or directory: '/Users/.../PycharmProjects/untitled1/dist/app/jaeger/core/../etc/jaeger.yml'

[6348] Failed to execute script app

看来PyInstaller无法解决jaeger_client导入。 因此,一种简单的方法是只编辑您的spec文件并将整个jaeger_client库添加为Tree类:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['script.py'],
             ...)
a.datas += Tree('<python_path>/Lib/site-packages/jaeger_client', prefix='./jaeger_client')
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
...

并使用pyinstaller script.spec生成可执行文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM