Python3.7升级到3.9问题处理——OSError: [WinError 193] %1 is not a valid Win32 application
1. 完整报错内容
Traceback (most recent call last):
File "C:\Users\intel\Desktop\FOLDERS\Programming stuff\Python scripts\test.py", line 1, in <module>
import openpyxl
File "C:\Users\intel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\openpyxl\__init__.py", line 4, in <module>
from openpyxl.compat.numbers import NUMPY, PANDAS
File "C:\Users\intel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\openpyxl\compat\__init__.py", line 3, in <module>
from .numbers import NUMERIC_TYPES
File "C:\Users\intel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\openpyxl\compat\numbers.py", line 9, in <module>
import numpy
File "C:\Users\intel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\intel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
2.解决方法
pip uninstall numpy
pip uninstall openpyxl
pip install numpy
pip install openpyxl