简体   繁体   English

执行python cgi脚本时出现“504网关超时”

[英]"504 Gateway Timeout" while executing python cgi script

The following example code:以下示例代码:

#!/usr/bin/python3
from astropy.time import Time
from astropy.coordinates import solar_system_ephemeris, EarthLocation, get_body

print('Content-Type:text/html;charset=utf-8\n')

t = Time("2014-09-22 23:22")
loc = EarthLocation.of_site('greenwich') 
with solar_system_ephemeris.set('builtin'):
    jup = get_body('jupiter', t, loc) 
print('<h2>',jup.ra.deg,'</h2>')  

works OK when the script runs locally (=136.9111620895066).当脚本在本地运行时正常工作 (=136.9111620895066)。 But if I try to execute it from the server a "504 Gateway Time-out" Nginx error appears.但是,如果我尝试从服务器执行它,则会出现“504 网关超时”Nginx 错误。

Maybe something is wrong with the file where astropy holds the ephemerides data?也许 astropy 保存星历数据的文件有问题? Other astropy, matplotlib, etc. scripts work fine from the server.其他 astropy、matplotlib 等脚本在服务器上运行良好。 The error appears every time the script needs ephemerides flles (jpl, esa ...).每次脚本需要星历表(jpl,esa ...)时都会出现该错误。

确保您拥有 astropy 的最新错误修复版本(v3.2.3, http ://docs.astropy.org/en/latest/changelog.html#id153),因为它修复了 IERS URL 的问题,这可能是导致您出现“504 网关超时”错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM