2

So, I keep getting this error:

OSError: [WinError 193] %1 is not a valid Win32 application

I believed it to be because of my environment variables. So, I fixed that, but still keep getting the error. I'm at a loss currently. Here's the complete error output:

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

Edit: Here is the code I'm trying to run.

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))

Edit 2: My os is Windows 10 and running on x64

Migster_Fixer
  • 31
  • 1
  • 4
  • This looks vaguely like you tried to run a Mac or Linux build on Windows, can you add details to clarify this? How exactly and from where exactly did you install NLTK? Also, it would be useful if you could find out which DLL exactly it's trying to load. – tripleee Jun 12 '20 at 04:31
  • Hello and welcome to SO! Please review the guide on [How to ask a good question](https://stackoverflow.com/help/how-to-ask). It's really hard to answer a question where you provide so little information. What system are you running? What code are you trying to execute that throws this error? This should all be included in your post. – NotAName Jun 12 '20 at 04:46
  • I'm sorry pavel! I'll include more details! And tripleee, I'm running windows. I installed nltk from pip installer, and i wish i knew the DLL it needs for it to load. – Migster_Fixer Jun 12 '20 at 06:32

3 Answers3

0
OSError: [WinError 193] %1 is not a valid Win32 application

Maybe your computer's OS is not window_32, But your python version is 32-bit. So check your OS, I guess your OS is window_64, And install right python version.

Here is python installer for window_64.

python installer for win_64

Singh
  • 504
  • 4
  • 15
han
  • 146
  • 7
0

I ran into the same OS error using, win_64 Bit and I have both python 32-bit and 64-bit installed. The problem is definitely the nltk module.

on the nltk documentation, the [nltk webpage] (https://www.nltk.org/install.html) suggests to install Windows 32-bit versions of python. Try python 32.

I would have just done a comment but I have no reputation.

0

Also as described in this link make sure you are using a 64 bit console e.g.

C:\Windows\SysWOW64\cmd.exe

while using pip to install your dependencies. This ensures the 64 bit version of the dependencies is installed. Also make sure you are using Python 64 bits and if loading any external .dll or .so compiled in C it was compiled using 64 bits.

VMMF
  • 906
  • 1
  • 17
  • 28