Pyinstaller 语法错误:异步函数中的“yield"(Python 3.5.1)

编程入门 行业动态 更新时间:2024-10-25 04:22:37
本文介绍了Pyinstaller 语法错误:异步函数中的“yield"(Python 3.5.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用 pyinstaller 创建单个可执行文件以分发给未安装 Python 的用户.

I am trying to use pyinstaller to create a single executable to distribute to users without Python installed.

该脚本非常简单,只是为了试水,我只使用了几行代码作为豚鼠".

The script is a very simple one and just to test waters I'm using just a few lines of code as "Guinea Pig".

Hello World 程序 - 没有导入,转换良好.

The Hello World program - no imports, converts fine.

导入 matplotlib.pyplot 并绘制值列表的豚鼠程序失败了.

My Guinea Pig program, which imports matplotlib.pyplot and plots a list of values, fails.

该问题是已知的并记录在此处,尽管他们声称已修复,或者也许我无法正确阅读.我认为修复应该在开发版本"中可用,应该是 3.2.1,我已经通过 pip install --upgrade pyinstaller 安装,但无济于事.

The issue is known and documented here, although they claim it is fixed, or maybe I can't read correctly. I think the fix should be available in the "dev version" which should be 3.2.1, and I have installed through pip install --upgrade pyinstaller, to no avail.

我不断收到相同的语法错误,这是在阅读

I keep getting the same syntax error, which occurs when reading the

module jinja2\asyncsupport.py

知道如何解决这个问题吗?我的项目非常简单,它只涉及matplotlib、pandas、读取文件和绘制一些数据.

Any idea how to work around this? My project is ultra simple and it just involves matplotlib, pandas, reading a file and plotting some data.

推荐答案

我遇到了同样的错误.

原因是 Jinja2 在 2.9 版本中为 Python3.6 添加了新的异步函数.

The reason is Jinja2 added new async function for Python3.6 in version 2.9.

请参阅jinja.pocoo/docs/2.9/changelog/#version-2-9-6

有两种方法可以避免此错误.这两个都对我有用.

There are two ways to avoid this error. Both of these worked for me.

  • 降级 jinja2

  • Downgrade jinja2 # using Anaconda conda install jinja2=2.8.1 # using pip pip install jinja2==2.8.1

  • 安装开发版的 PyInstaller

  • Install dev version of PyInstaller

    # install from github # Don't run "pip install -U pyinstaller" because the dev version is not released yet pip install git+github/pyinstaller/pyinstaller.git # check if "PyInstaller (3.3.dev0+g483dfde)" is in the list pip list

  • 更多推荐

    Pyinstaller 语法错误:异步函数中的“yield"(Python 3.5.1)

    本文发布于:2023-11-23 13:48:40,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1621654.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:函数   语法错误   Pyinstaller   yield   Python

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!