async
and await
have been added to the reserved keywords since python3.7. Reference: python.org/3.7/whatsnew/3.7.html" rel=" nofollow noreferrer > What's New In Python 3.7 , so async
and await
cannot be used as parameter names of functions.
such as class
is also an internally reserved keyword:
>>> def foo(class=None, bar=None):
File "<stdin>", line 1
def foo(class=None, bar=None):
^
SyntaxError: invalid syntax
see which keywords can be used keyword
module, for example, in python3.6:
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
Let's take a look at the partial source code of ider" rel=" nofollow noreferrer > pyspider :
ider/blob/master/pyspider/run.py-sharpL231" rel=" nofollow noreferrer "run.py :
.
def fetcher(ctx, xmlrpc, xmlrpc_host, xmlrpc_port, poolsize, proxy, user_agent,
timeout, phantomjs_endpoint, splash_endpoint, fetcher_cls,
async=True, get_object=False, no_input=False):
here async
is used as the parameter name, so an error will be reported under python3.7.
to sum up, you need to solve this problem, you can:
- lower your python version, for example, to python3.5
- tells the author of pyspider that the author should modify the code and do not use
async
as the parameter name to make the code compatible with python3.7.. Refer to this ider/pull/803" rel=" nofollow noreferrer "> Pull Request .
@ vibiu see that you merged this PR, with issue-sharp803, so why does the latest version of v0.3.10 still have this problem?
there is still this problem
I installed with anaconda, you can use the command: conda install python=3.6 to lower the python version
agree to the first floor, just replace the async (for example, change it to shark), and be careful not to change the part of the import package.