码迷,mamicode.com
首页 > Web开发 > 详细

PyExecJs报错解决

时间:2019-07-29 00:50:42      阅读:396      评论:0      收藏:0      [点我收藏+]

标签:来源   port   syn   ams   tom   except   abs   extern   params   

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报错解决

标签:来源   port   syn   ams   tom   except   abs   extern   params   

原文地址:https://www.cnblogs.com/liuer-mihou/p/11261526.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!