很遗憾,我无法将PyInstaller与jaeger
一起使用。问题是PyInstaller和jaeger
之间存在某种节俭错误。
就像讨论的here。
它们是否有任何变通方法或修复程序?
我已经使用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
答案 0 :(得分: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
生成可执行文件。