Python - importing fastai results in SyntaxError
I am trying to setup an ML model using fastai and have to do the following imports: 

import fastai.models
import fastai.nlp
import fastai.dataset


However, it gives me the following error by the fastai imports. 

Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import fastai.nlp
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/local/lib/python2.7/dist-packages/fastai/nlp.py", line 172
    if os.path.isdir(path): paths=glob(f'{path}/*.*')
                                                   ^
SyntaxError: invalid syntax


Apparently, the character f in glob(f'{path}/*.*') is causing the error. I fixed the error by removing f, but it seems that there are lots of these errors in the fastai library. 

My current thought is that I am using an incorrect python version. Could anyone give me some pointer? 

Strings in the shape of:

f'{path}/*.*'


are called f-strings and were introduced in Python3.6.
That's why you get the SyntaxError - for versions lower than Python3.6 a SyntaxError will be raised, as this syntax just doesn't exist in lower versions. 

So obviously fast-ai is programmed for Python3.6 or higher.

When you take a look at the installation issues (you have to scroll down a bit),
you can see under Is My System Supported? the first point:


  Python: You need to have python 3.6 or higher


So I'm afraid updating your python is the easiest way to solve the problem!



If you like to learn more about f-strings you can take a look here: https://www.python.org/dev/peps/pep-0498/
