当将matplotlib.pyplot导入为plt时,导入失败。
我试图删除Python,Visual Studio Code,所有补充文件都已卸载并重新安装。
import win32com.client
import sys
import os
import textwrap
import time
import numpy
import matplotlib.pyplot as plt
这是终端显示的消息:
c:\Users\stsagale\Desktop\MasterThesis\Codes>python -c "import matplotlib"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\stsagale\AppData\Local\Programs\Python\Python37-32\lib\site-packages\matplotlib\__init__.py", line 138, in <module>
from . import cbook, rcsetup
File "C:\Users\stsagale\AppData\Local\Programs\Python\Python37-32\lib\site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
import numpy as np
File "C:\Users\stsagale\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\stsagale\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\stsagale\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 ist keine zulässige Win32-Anwendung
答案 0 :(得分:0)
您可以尝试:
import numpy as np
阅读错误,我认为这很重要。 否则,您是否使用virtualenv(https://www.python.org/dev/peps/pep-0405/)? 它可以帮助防止碰撞问题。
pip install virtualenv
virtualenv env
source /path/to/ENV/bin/activate
完成后
deactivate