最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - SyntaxError: Non-UTF-8 code starting with 'xb9' in pyz - Stack Overflow

programmeradmin4浏览0评论

I have a pyz that I'm building on GitHub using an Ubuntu docker container.

We're using poetry's pyinstaller command. something like:

poetry run pyinstaller test_pyz.spec --noconfirm --distpath build/pyz

The test_pyz.spec file has # -*- mode: python ; coding: utf-8 -*- at the top.

When I take the file and copy it to a Mac and run python3 test.pyz I am getting the following error:

SyntaxError: Non-UTF-8 code starting with '\xb9' in file 
/tmp/test.pyz on line 2, but no encoding declared; see 
/ for details

I have tried also setting an environment variable before the poetry command but have the same problem:

PYTHONIOENCODING=utf-8 poetry run pyinstaller test_pyz.spec --noconfirm --distpath build/pyz

Any suggestions on what else to check for? It seems like all of the encoding is correct so I'm not sure what's going on here.

After some more thought, I don't think we're creating a true pyz but a python executable via pyinstaller. Are we using this wrong?

I have a pyz that I'm building on GitHub using an Ubuntu docker container.

We're using poetry's pyinstaller command. something like:

poetry run pyinstaller test_pyz.spec --noconfirm --distpath build/pyz

The test_pyz.spec file has # -*- mode: python ; coding: utf-8 -*- at the top.

When I take the file and copy it to a Mac and run python3 test.pyz I am getting the following error:

SyntaxError: Non-UTF-8 code starting with '\xb9' in file 
/tmp/test.pyz on line 2, but no encoding declared; see 
http://python./dev/peps/pep-0263/ for details

I have tried also setting an environment variable before the poetry command but have the same problem:

PYTHONIOENCODING=utf-8 poetry run pyinstaller test_pyz.spec --noconfirm --distpath build/pyz

Any suggestions on what else to check for? It seems like all of the encoding is correct so I'm not sure what's going on here.

After some more thought, I don't think we're creating a true pyz but a python executable via pyinstaller. Are we using this wrong?

Share Improve this question edited Mar 26 at 20:42 Andre Gagne asked Mar 26 at 20:23 Andre GagneAndre Gagne 316 bronze badges 1
  • Edit the question and try to make a minimal reproducible example. – Mark Tolonen Commented Mar 26 at 20:44
Add a comment  | 

1 Answer 1

Reset to default 0

After looking more into https://pyinstaller./en/stable/operating-mode.html

I am realizing that although we name the file .pyz it is, in fact, not a .pyz but an executable for Ubuntu

发布评论

评论列表(0)

  1. 暂无评论