导入Matplotlib的问题



我在导入matplotlib时有问题。我使用:WPy64-3850和sypder.

File "D:tkminek_localPYTHONDAMPINGpokus.py", line 1, in <module>
from matplotlib import pyplot as plt
File "D:instalackyWPy64-3850python-3.8.5.amd64Libsite-packagesmatplotlib__init__.py", line 822, in <module>
rcParamsDefault = _rc_params_in_file(
File "D:instalackyWPy64-3850python-3.8.5.amd64Libsite-packagesmatplotlib__init__.py", line 727, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "D:instalackyWPy64-3850python-3.8.5.amd64libcontextlib.py", line 113, in __enter__
return next(self.gen)
File "D:instalackyWPy64-3850python-3.8.5.amd64Libsite-packagesmatplotlib__init__.py", line 701, in _open_file_or_url
fname = os.path.expanduser(fname)
File "D:instalackyWPy64-3850python-3.8.5.amd64libntpath.py", line 293, in expanduser
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not WindowsPath

有什么建议吗?

这可能是创建WindowsPath对象的特定于平台的库的冲突。在你的情况下,我会尝试那些:

  • 不同版本的matplotlib
pip uninstall matplotlib
pip install matplotlib==some_version
  • 重新安装python
  • 安装不同的python版本

你应该试着找出windows路径对象是在哪里创建的,这样你就可以把它改成string(使用str),这可能会解决这个问题。

我也会尝试

import matplotlib.pyplot as plt

最新更新