import matplotlib.pyplot as plt
/home/yttt/.local/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3agg.py:17: UserWarning: The Gtk3Agg backend is known to not work on Python 3.x with pycairo. Try installing cairocffi.
"The Gtk3Agg backend is known to not work on Python 3.x with pycairo. "
>>> import scipy.io as sio
>>> import numpy as np
>>> from torch.utils.data import Dataset,DataLoader
>>> from sklearn.metrics import confusion_matrix
import os>>> import os
>>> import time
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/pandas-0.22.0-py3.6-linux-armv7l.egg/pandas/__init__.py", line 58, in <module>
from pandas.io.api import *
File "/usr/local/lib/python3.6/dist-packages/pandas-0.22.0-py3.6-linux-armv7l.egg/pandas/io/api.py", line 19, in <module>
from pandas.io.packers import read_msgpack, to_msgpack
File "/usr/local/lib/python3.6/dist-packages/pandas-0.22.0-py3.6-linux-armv7l.egg/pandas/io/packers.py", line 68, in <module>
from pandas.util._move import (
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 2: invalid start byte
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/pandas-0.22.0-py3.6-linux-armv7l.egg/pandas/__init__.py", line 51, in <module>
plot_params = pandas.plotting._style._Options(deprecated=True)
AttributeError: module 'pandas' has no attribute 'plotting'
>>> exit()
yttt@xilinx:~/yt$ python3
Python 3.6.9 (default, Jun 29 2022, 11:45:57)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> exit()
yttt@xilinx:~/yt$
yttt@xilinx:~/yt$ python3
Python 3.6.9 (default, Jun 29 2022, 11:45:57)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> matplotlib.use("Pdf")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'matplotlib' is not defined
>>> import matplotlib
>>> matplotlib.use("Pdf")
>>> import matplotlib.pyplot as plt
>>> import pandas as pd
>>> exit()
在import matplotlib.pyplot as plt时报错:
/home/yttt/.local/lib/python3.6/site-packages/matplotlib/backends/backend_gtk3agg.py:17: UserWarning: The Gtk3Agg backend is known to not work on Python 3.x with pycairo. Try installing cairocffi.
"The Gtk3Agg backend is known to not work on Python 3.x with pycairo. "
解决办法:
在代码import matplotlib.pyplot as plt前添加:
import matplotlib
matplotlib.use("Pdf")