Using python to execute js code on centos reports an error--Could not find an available JavaScript runtime.

Article Directory

problem,

I am executing the python code error on the centos7.2 version of ecs:
error code:

Traceback (most recent call last):
  File "3_sub_demand_id_493_search_key.py", line 262, in <module>
    spider_315_search_key_sub_demand_id_532.run_spider_all_key(keyword)
  File "3_sub_demand_id_493_search_key.py", line 62, in run_spider_all_key
    self.get_key_page_data(page, key)
  File "3_sub_demand_id_493_search_key.py", line 88, in get_key_page_data
    get_code = self.get_list_code(data)
  File "3_sub_demand_id_493_search_key.py", line 55, in get_list_code
    ctx = execjs.compile(js_str1)
  File "/usr/local/lib/python3.6/site-packages/execjs/__init__.py", line 61, in compile
    return get().compile(source, cwd)
  File "/usr/local/lib/python3.6/site-packages/execjs/_runtimes.py", line 21, in get
    return get_from_environment() or _find_available_runtime()
  File "/usr/local/lib/python3.6/site-packages/execjs/_runtimes.py", line 49, in _find_available_runtime
    raise exceptions.RuntimeUnavailableError("Could not find an available JavaScript runtime.")
execjs._exceptions.RuntimeUnavailableError: Could not find an available JavaScript runtime.

Solution:

This is because the nodejs environment is not installed on centos, and the js code cannot be executed:

yum install epel-release
yum install nodejs

Insert picture description here

Then execute the code.

Guess you like

Origin blog.csdn.net/weixin_42081389/article/details/106897456