Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyinstaller Syntax error: 'yield' inside async function (Python 3.5.1)

Tags:

pyinstaller

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".

The Hello World program - no imports, converts fine.

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

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

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.

like image 549
Michele Ancis Avatar asked Apr 01 '17 23:04

Michele Ancis


1 Answers

I got the same error.

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

Please see http://jinja.pocoo.org/docs/2.9/changelog/#version-2-9-6

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

  1. Downgrade jinja2

       # using Anaconda
       conda install jinja2=2.8.1
    
       # using pip
       pip install jinja2==2.8.1
    
  2. 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+https://github.com/pyinstaller/pyinstaller.git
    
      # check if "PyInstaller (3.3.dev0+g483dfde)" is in the list
      pip list
    
like image 126
Kenji Avatar answered Sep 22 '22 16:09

Kenji