![如何修复本机 python/pandas 问题:TypeError: 'type' 对象的描述符 '__subclasses__' 需要一个参数](https://linux22.com/image/1169977/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%E6%9C%AC%E6%9C%BA%20python%2Fpandas%20%E9%97%AE%E9%A2%98%EF%BC%9ATypeError%3A%20'type'%20%E5%AF%B9%E8%B1%A1%E7%9A%84%E6%8F%8F%E8%BF%B0%E7%AC%A6%20'__subclasses__'%20%E9%9C%80%E8%A6%81%E4%B8%80%E4%B8%AA%E5%8F%82%E6%95%B0.png)
我全新安装了 Ubuntu 16.04.6,在安装了一些 Python 包(如下所列)并输入 Python3 后import pandas
,出现此错误:
myBashPrompt:~$ python3
Python 3.5.2 (default, Oct 8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/anon/.local/lib/python3.5/site-packages/pandas/__init__.py", line 55, in <module>
from pandas.core.api import (
File "/home/anon/.local/lib/python3.5/site-packages/pandas/core/api.py", line 5, in <module>
from pandas.core.arrays.integer import (
File "/home/anon/.local/lib/python3.5/site-packages/pandas/core/arrays/__init__.py", line 1, in <module>
from .array_ import array # noqa: F401
File "/home/anon/.local/lib/python3.5/site-packages/pandas/core/arrays/array_.py", line 7, in <module>
from pandas.core.dtypes.common import (
File "/home/anon/.local/lib/python3.5/site-packages/pandas/core/dtypes/common.py", line 11, in <module>
from pandas.core.dtypes.dtypes import (
File "/home/anon/.local/lib/python3.5/site-packages/pandas/core/dtypes/dtypes.py", line 53, in <module>
class Registry:
File "/home/anon/.local/lib/python3.5/site-packages/pandas/core/dtypes/dtypes.py", line 84, in Registry
self, dtype: Union[Type[ExtensionDtype], str]
File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
dict(self.__dict__), parameters, _root=True)
File "/usr/lib/python3.5/typing.py", line 512, in __new__
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__
if super().__subclasscheck__(cls):
File "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__
for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
我该如何修复或避免此错误?
上次发布此帖时,我以为是因为我升级了 Ubuntu。升级不是问题。这些是我安装的其他软件包。
pip3 install pygame
pip3 install pymunk
pip3 install numpy
pip3 install matplotlib==3.0.3 #installed older version because new version requires python3.6
pip3 install scipy
pip3 install PyQt5
sudo pip3 install pyqtgraph
sudo apt-get install openmpi-bin
pip3 install cntk
pip3 install h5py
sudo pip3 install keras
pip3 install visvis --user
pip3 install seaborn --user
pip3 install pandas