无法导入matplotlib pyplot

p5fdfcr1  于 2022-12-13  发布在  其他
关注(0)|答案(2)|浏览(194)

我无法导入pyplot。如何解决这个错误?

>>> from matplotlib import pyplot
Jul 16 12:49:46  Python[35767] <Error>: Set a breakpoint at CGSLogError to catch errors as they are logged.
Jul 16 12:49:46  Python[35767] <Error>: On-demand launch of the Window Server is allowed for root user only.
Jul 16 12:49:46  Python[35767] <Warning>: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (268435459)
Jul 16 12:49:46  Python[35767] <Error>: On-demand launch of the Window Server is allowed for root user only.
Jul 16 12:49:46  Python[35767] <Warning>: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (268435459)
Jul 16 12:49:46  Python[35767] <Error>: This user is not allowed access to the window system right now.
_RegisterApplication(), unable to get application ASN from launchservicesd, and this application requires an ASN, so aborting.  error=#-1.
Abort trap: 6
yquaqz18

yquaqz181#

要使用该库,需要先安装它。可以从official site安装它。
在Ubuntu中,可以通过apt-get获取:

sudo apt-get install python-matplotlib

在Windows中,对于标准Python安装,请使用pip安装matplotlib:

python -m pip install -U pip setuptools
python -m pip install matplotlib
vngu2lb8

vngu2lb82#

您没有正确安装它您应该通过pip安装它,如python -m pip install -u pip setuptools python -m pip install matplotlib
(This方法仅适用于Windows)

相关问题