0

不幸的是,我无法将 PyInstaller 与jaeger. 问题是 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)


脚本按预期运行 -> 创建 Span 并启动 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
4

1 回答 1

0

PyInstaller 似乎无法解析jaeger_client导入。所以一个简单的方法是编辑你的规范文件并将整个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.

于 2019-07-15T12:06:42.750 回答