NLTK无法使用CGI脚本

时间:2017-11-03 05:42:58

标签: python cgi nltk

#![path_to_python_interpreter]
import sys
print("Content-type: text/html\n\n")
print(sys.version)

以上代码在Web浏览器上完美运行(localhost:8081 / cgi-bin / script.py)。但是,当我添加import nltk时,它不起作用,并给出错误:"在标题之前输出脚本结束:script.py"。但是,nltk适用于python命令行解释器,并且python版本名称也匹配。所以我认为问题肯定是因为CGI。我使用的是64位Windows 10.这是我的python版本(32位):

  

3.6.0(v3.6.0:41df79263a11,2016年12月23日,07:18:10)[MSC v.1900 32 bit(Intel)]

以下是导入nltk时的Apache错误日志:

  

[Fri Nov 03 10:58:07.813627 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010]标题前脚本输出结束:script.py

     

[Fri Nov 03 10:58:07.813627 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:Traceback(最近一次调用最后一次):\ r:C:/ XAMPP /的cgi-bin / script.py

     

[Fri Nov 03 10:58:07.814125 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:File" C:/ xampp / cgi-bin / script.py",第3行,在\ r:C:/xampp/cgi-bin/script.py

     

[Fri Nov 03 10:58:07.814125 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:import nltk \ r:C:/ xampp / cgi-bin / script.py

     

[Fri Nov 03 10:58:07.814628 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:File" C:\ Users \ slaYer \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ nltk \ __ init __。py",第160行,在\ r:C:/xampp/cgi-bin/script.py

     

[Fri Nov 03 10:58:07.814628 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:来自nltk.downloader导入下载,download_shell \ r:C:/ XAMPP /的cgi-bin / script.py

     

[Fri Nov 03 10:58:07.815124 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:File" C:\ Users \ slaYer \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ nltk \ downloader.py",第2233行,在\ r:C:/xampp/cgi-bin/script.py

     

[Fri Nov 03 10:58:07.815124 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:_downloader = Downloader()\ r \ n:C:/ xampp / cgi -bin / script.py

     

[Fri Nov 03 10:58:07.815124 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:File" C:\ Users \ slaYer \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ nltk \ downloader.py",第437行,在 init \ r:C:/ xampp / cgi-bin / script的.py

     

[Fri Nov 03 10:58:07.815625 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:self._download_dir = self.default_download_dir()\ r:C: /xampp/cgi-bin/script.py

     

[Fri Nov 03 10:58:07.815625 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:File" C:\ Users \ slaYer \ AppData \ local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ nltk \ downloader.py",第946行,在default_download_dir \ r中:C:/xampp/cgi-bin/script.py

     

[Fri Nov 03 10:58:07.816127 2017] [cgi:error] [pid 6796:tid 1844] [客户   :: 1:57010] AH01215:引发ValueError("找不到默认下载目录")\ r:C:/xampp/cgi-bin/script.py

     

[Fri Nov 03 10:58:07.816127 2017] [cgi:error] [pid 6796:tid 1844] [client :: 1:57010] AH01215:ValueError:找不到默认的下载目录\ r \ n:C: /xampp/cgi-bin/script.py

0 个答案:

没有答案