pippython-3.5mlxtend

basic mlxtend example giving invalid syntax error


I'm using Python 3.5.2 on Ubuntu 16.04.

I've installed sklearn using..

sudo apt install python-sklearn

and mlxtend using...

sudo pip3 install mlxtend

I'm trying to run the basic Iris example found on the Internet, but I am getting an error as soon as I try to import plot_decision_regions from mlxtend.plotting:

from mlxtend.plotting import plot_decision_regions


Traceback (most recent call last):
  File "scripts/machine.learning.py", line 6, in <module>
    from mlxtend.plotting import plot_decision_regions
  File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/__init__.py", line 15, in <module>
    from .heatmap import heatmap
  File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/heatmap.py", line 74
    raise AssertionError(f'len(row_names) (got {len(row_names)})'
                                                                ^
SyntaxError: invalid syntax

Solution

  • I had the same error, just upgrade to python3.7 the real error is

    python 3.5 does not support f prefix

    upgrade using conda

    conda install -c anaconda python=3.7
    

    and then update all depencies

    conda update --all