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

Question:

I installed wordcloud

pip install wordcloud

Then I imported wordcloud

import wordcloud
import numpy as np
from matplotlib import pyplot as plt
from IPython.display import display
import io
import sys

I got this error:

OSError   Traceback (most recent call last) <ipython-input-84-dc1828f2a80e> in <module>
----> 1 import wordcloud

~AppDataRoamingPythonPython38site-packageswordcloud__init__.py in <module>
----> 1 from .wordcloud import (WordCloud, STOPWORDS, random_color_func,
      2                         get_single_color_func)
      3 from .color_from_image import ImageColorGenerator
      4 
      5 __all__ = ['WordCloud', 'STOPWORDS', 'random_color_func',

~AppDataRoamingPythonPython38site-packageswordcloudwordcloud.py in <module>
     17 import sys
     18 import colorsys
---> 19 import matplotlib
     20 import numpy as np
     21 from operator import itemgetter

~AppDataRoamingPythonPython38site-packagesmatplotlib__init__.py in <module>
    105 # cbook must import matplotlib only within function
    106 # definitions, so it is safe to import from it here.
--> 107 from . import cbook, rcsetup
    108 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
    109 from matplotlib.cbook import mplDeprecation  # deprecated

~AppDataRoamingPythonPython38site-packagesmatplotlibcbook__init__.py in <module>
     26 import weakref
     27 
---> 28 import numpy as np
     29 
     30 import matplotlib

~AppDataRoamingPythonPython38site-packagesnumpy__init__.py in <module>
    136 
    137     # Allow distributors to run custom init code
--> 138     from . import _distributor_init
    139 
    140     from . import core

~AppDataRoamingPythonPython38site-packagesnumpy_distributor_init.py in <module>
     24                 # NOTE: would it change behavior to load ALL
     25                 # DLLs at this path vs. the name restriction?
---> 26                 WinDLL(os.path.abspath(filename))
     27                 DLL_filenames.append(filename)
     28         if len(DLL_filenames) > 1:

C:ProgramDataAnaconda3libctypes__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    379 
    380         if handle is None:
--> 381             self._handle = _dlopen(self._name, mode)
    382         else:
    383             self._handle = handle

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

||

Answers:

Numpy that you have installed doesn’t have correct libs for ctypes. Probably it is 32bit version, and your system has 64bit architecture or vice versa. Or you lunching it with incompatible python interpreter.
Please try to lunch it with both, 32 and 64 bit python interpreter.

Answered By: George

I resolved problem.

  1. I uninstalled Anaconda
  2. I deleted Python folder in : C:UsersAdminAppDataRoaming
  3. I removed .conda folder in C:UsersAdmin
  4. I installed Anaconda
  5. I insert into C:WindowsSystem32, pythoncom38.dll and
    pywintypes38.dll from C:ProgramDataAnaconda3Libsite-packages
  6. I uninstalled wordcloud and Numpy, then installed

pip uninstall wordcloud
pip uninstall Numpy
pip install wordcloud
pip install Numpy

Answered By: Beso
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.