我正在尝试在 Apache 上的浏览器中执行 Julia 代码(我在 Windows 10 上使用 Ampps)。我能够执行它真正的命令提示符或通过 python 代码调用它(参见下面的 python 代码)。当我尝试直接在浏览器上执行 Julia 代码时,我收到网关超时服务器未及时响应消息。但是当我尝试执行调用 Julia 代码的 python 代码时,我会在 Apache 的错误日志中获得更详细的信息:
fatal: error thrown and no exception handler available.:C:/Program Files
(x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
rec_backtrace at /home/Administrator/buildbot/slave/package_win6_2-x64/build
/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\stackwalk.c:84:
C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer:
http://localhost/csvToLayer_JSAPI/
record_backtrace at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home
/Administrator/buildbot/slave/package_win6_2-x64/build/src\\task.c:233:
C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py,
referer: http://localhost/csvToLayer_JSAPI/
jl_throw at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\task.c:551:
C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
access_env at .\\env.jl:14: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py,referer:
http://localhost/csvToLayer_JSAPI/
homedir at .\\path.jl:41: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer:
http://localhost/csvToLayer_JSAPI/
_pkgroot at .\\pkg\\dir.jl:10 [inlined]: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py,
referer: http://localhost/csvToLayer_JSAPI/
__init__ at .\\pkg\\pkg.jl:74: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py,
referer: http://localhost/csvToLayer_JSAPI/
unknown function (ip: 0000000061D151DE): C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py,
referer: http://localhost/csvToLayer_JSAPI/
jl_call_method_internal at /home/Administrator/buildbot/slave
/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\julia_internal.h:210 [inlined]:
C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
jl_apply_generic at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\gf.c:1950: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
jl_apply at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\julia.h:1392 [inlined]:
C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py,
referer: http://localhost/csvToLayer_JSAPI/
jl_module_run_initializer at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\toplevel.c:83: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
_julia_init at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\init.c:742:
C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer:
http://localhost/csvToLayer_JSAPI/
julia_init at /home/Administrator/buildbot/slave/package_win6_2-x64/build/src/home/Administrator/buildbot/slave/package_win6_2-x64/build/src\\task.c:284: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
wmain at /home/Administrator/buildbot/slave/package_win6_2-x64/build/ui\\repl.c:242: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
__tmainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-4.0.6-1/crt\\crtexe.c:329: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
mainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-4.0.6-1/crt\\crtexe.c:212: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
BaseThreadInitThunk at C:\\WINDOWS\\System32\\KERNEL32.DLL (unknown line): C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
RtlUserThreadStart at C:\\WINDOWS\\SYSTEM32\\ntdll.dll (unknown line): C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
Base.InitError(mod=:Pkg, error=Base.KeyError(key="HOMEDRIVE")): C:/Program Files (x86)/
Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
Traceback (most recent call last):\r: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
File "C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py", line 20, in
<module>\r: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer:
http://localhost/csvToLayer_JSAPI/
x = subprocess.check_output(cmd)\r: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer:
http://localhost/csvToLayer_JSAPI/
File "C:\\Python27\\ArcGIS10.3\\lib\\subprocess.py", line 573, in check_output\r:
C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
raise CalledProcessError(retcode, cmd, output=output)\r: C:/Program Files (x86)/
Ampps/www/csvToLayer_JSAPI/python.py, referer: http://localhost/csvToLayer_JSAPI/
subprocess.CalledProcessError: Command '['C:/Users/Reza/AppData/Local/Julia-0.5.1/bin/julia.exe',
'C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/HT.jl']' returned non-zero exit status
-1073741510\r: C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/python.py,
referer: http://localhost/csvToLayer_JSAPI/
这似乎是一个与如何在 Julia 中设置 APPDATA env 变量有关的已知问题。这里建议将HOMEDRIVE、HOMEPATH 和APPDATA 的环境变量设置在httpd.conf 或httpd-vhosts.conf 中。我尝试同时编辑 httpd-vhosts.conf 和 httpd.conf,但我仍然得到同样的错误。
这就是我编辑 httpd.conf 的方式:
#### Localhost VirtualHost ####
<VirtualHost 127.0.0.1:80>
<Directory "{$path}/www">
Options Indexes FollowSymLinks ExecCGI
AddHandler cgi-script .cgi .py .jl
AllowOverride All
Order deny,allow
allow from All
</Directory>
SetEnv HOMEDRIVE "C:"
SetEnv HOMEPATH "/Users/Reza"
SetEnv APPDATA "C:/Users/Reza/AppData/Roaming"
ScriptLog logs/julia_cgi.log
ServerName localhost
ServerAlias localhost 127.0.0.1
ScriptAlias /cgi-bin/ "{$path}/www/cgi-bin/"
DocumentRoot "{$path}/www"
ErrorLog "{$path}/apache/logs/error.log"
CustomLog "{$path}/apache/logs/access.log" combined
</VirtualHost>
这是调用 Julia 代码的 python 代码:
#!"C:/Python27/ArcGIS10.3/python.exe"
import subprocess
print "Content-Type: text/html\n\n"
print "hi there! this is python!"
command="C:/Users/Reza/AppData/Local/Julia-0.5.1/bin/julia.exe"
path2script="C:/Program Files (x86)/Ampps/www/csvToLayer_JSAPI/HT.jl"
cmd = [command, path2script]
x = subprocess.check_output(cmd)
print x
这是 Julia 代码:
#!"C:/Users/Reza/AppData/Local/Julia-0.5.1/bin/julia.exe"
redirect_stderr(STDOUT)
println("Content-Type: text/html\n\n")
println("hi there; this is Julia!");
println("Julia is passing outputs to Python");
我是否为 APPDATA 环境变量设置了一个错误的位置?我应该为 APPDATA 使用哪个文件夹?除了“C:/Users/Reza/AppDate/Roaming”之外,我还尝试了“C:/Users/Reza/AppDate/Local”和“C:/Users/Reza/AppDate/Local/Julia-0.5.1” ,我得到同样的错误。