PyExecJs报错解决
Posted liuer-mihou
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PyExecJs报错解决相关的知识,希望对你有一定的参考价值。
Traceback (most recent call last): File "D:/python-file/algorithm/spider_air.py", line 22, in <module> params = ctx.eval(js) File "C:\Users\Since\AppData\Local\Programs\Python\Python36\lib\site-packages\execjs\_abstract_runtime_context.py", line 28, in eval return self._eval(source) File "C:\Users\Since\AppData\Local\Programs\Python\Python36\lib\site-packages\execjs\_external_runtime.py", line 76, in _eval return self.exec_(code) File "C:\Users\Since\AppData\Local\Programs\Python\Python36\lib\site-packages\execjs\_abstract_runtime_context.py", line 19, in exec_ return self._exec_(source) File "C:\Users\Since\AppData\Local\Programs\Python\Python36\lib\site-packages\execjs\_external_runtime.py", line 88, in _exec_ return self._extract_result(output) File "C:\Users\Since\AppData\Local\Programs\Python\Python36\lib\site-packages\execjs\_external_runtime.py", line 169, in _extract_result raise exceptions.RuntimeError(value) execjs._exceptions.RuntimeError: SyntaxError: 语法错误
错误来源于:execjs是驱动系统自带的Jscript去执行的js代码,如果没有或者其他原因汇报语法错误。 解决方法: import execjs import os # os.environ["EXECJS_RUNTIME"] = ‘Phantomjs‘ node = execjs.get() 将驱动变成:Phantomjs即可
完美解决!!!
以上是关于PyExecJs报错解决的主要内容,如果未能解决你的问题,请参考以下文章