Lanti Lanti - 3 months ago 12
Python Question

Invalid syntax error with numba installed with pip

When I try to run this Python code inside my

virtualenv
:

#!./env/bin/python3

from numba import jit
@jit(nopython=True)

print("Hello World")


I got the following error:

(env) root@LANTI-PC:/mnt/c/www/python/flask/app# ./test.py
File "./test.py", line 6
print("Hello World")
^
SyntaxError: invalid syntax


This is my
requirements.txt
:

click==6.6
Flask==0.11.1
funcsigs==1.0.2
itsdangerous==0.24
Jinja2==2.8
llvmlite==0.12.1
MarkupSafe==0.23
numba==0.27.0
numpy==1.11.1
pybars3==0.9.1
PyMeta3==0.5.1
Werkzeug==0.11.10


llvm-config
version:
3.7.1


Also, If I just do
import numba
or
from numba import jit
, the file will be executed, but marginally slower than if I execute with
python3
only, without any numba import.

Answer

Please remove your usage of @jit decorator, because there are no function to decorate there, they's why the error. Decorators wrap the functions so without them they are useless and erronous.