所以,我不断收到此错误:
OSError: [WinError 193] %1 is not a valid Win32 application
我认为这是因为我的环境变量。因此,我已修复该问题,但仍会继续收到错误消息。我现在不知所措。这是完整的错误输出:
Traceback (most recent call last):
File "c:\Users\angel\Desktop\Programming Related\Python\improvedTherapibot\copyImprovedBot.py", line 5, in <module>
import nltk
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\__init__.py", line 128, in <module>
from nltk.collocations import *
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\collocations.py", line 39, in <module>
from nltk.metrics import (
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\metrics\__init__.py", line 16, in <module>
from nltk.metrics.scores import (
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\metrics\scores.py", line 15, in <module>
from scipy.stats.stats import betai
File "C:\Users\angel\AppData\Roaming\Python\Python38\site-packages\scipy\__init__.py", line 106, in <module>
from . import _distributor_init
File "C:\Users\angel\AppData\Roaming\Python\Python38\site-packages\scipy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
编辑:这是我要运行的代码。
import nltk
from nltk.corpus import wordnet
good_words = []
bad_words = []
for syn in wordnet.synsets("happy"):
for l in syn.lemmas():
good_words.append(l.name())
for syn in wordnet.synsets("sad"):
for l in syn.lemmas():
bad_words.append(l.name())
print(set(good_words))
编辑2:我的操作系统是Windows 10,并且在x64上运行
答案 0 :(得分:0)
OSError: [WinError 193] %1 is not a valid Win32 application
也许您计算机的操作系统不是window_32,但是您的python才是合适的。因此,请检查您的操作系统,我猜您的操作系统是window_64,然后安装正确的python版本。
这是window_64的python安装程序。
答案 1 :(得分:0)
我使用win_64 Bit遇到相同的操作系统错误,并且同时安装了32位和64位python。问题肯定是nltk模块。
我本来会发表评论,但我没有声誉。