当我在Ubuntu16.04上使用python3中的seaborn.heatmap运行file1.py时,
我得到了错误消息:
Traceback (most recent call last):
File "file1.py", line 19, in <module>
import seaborn as sns
ImportError: No module named 'seaborn'然后我在终端中运行命令$ sudo apt install python3-seaborn:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libdsdp-5.8gf libglade2-0 libglpk36 python-cvxopt python-cycler
python-decorator python-glade2 python-imaging python-jdcal python-joblib
python-numexpr python-openpyxl python-pandas python-pandas-lib python-patsy
python-py python-pytest python-scipy python-statsmodels
python-statsmodels-lib python-tables python-tables-lib
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
python3-matplotlib
Suggested packages:
ffmpeg ipython3 python-matplotlib-doc python3-cairocffi python3-gobject
python3-nose python3-pyqt4 python3-sip python3-tornado ttf-staypuft
The following NEW packages will be installed:
python3-matplotlib python3-seaborn
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3,999 kB of archives.
After this operation, 13.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package python3-matplotlib.
(Reading database ... 378283 files and directories currently installed.)
Preparing to unpack .../python3-matplotlib_1.5.1-1ubuntu1_amd64.deb ...
Unpacking python3-matplotlib (1.5.1-1ubuntu1) ...
Selecting previously unselected package python3-seaborn.
Preparing to unpack .../python3-seaborn_0.6.0-1_all.deb ...
Unpacking python3-seaborn (0.6.0-1) ...
Setting up python3-matplotlib (1.5.1-1ubuntu1) ...
Setting up python3-seaborn (0.6.0-1) ...现在可以成功运行file1.py了,当我在python3中使用Axes3D运行file2.py时,我得到了错误消息:
Traceback (most recent call last):
File "file2.py", line 29, in <module>
from mpl_toolkits.mplot3d import Axes3D
File "/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/__init__.py", line 4, in <module>
from matplotlib.externals import six
ImportError: No module named 'matplotlib.externals'只有我运行$ sudo apt remove python3-matplotlib才能运行file2.py:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
fonts-lyx libjs-jquery-ui python-matplotlib-data python-tables-data python3-cycler
python3-dateutil python3-decorator python3-numexpr python3-pandas python3-pandas-lib python3-patsy
python3-scipy python3-tables python3-tables-lib python3-tz
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
python3-matplotlib python3-seaborn
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 13.8 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 375396 files and directories currently installed.)
Removing python3-seaborn (0.6.0-1) ...
Removing python3-matplotlib (1.5.1-1ubuntu1) ...但是,python3-seaborn也同时被移除。我该如何解决这个问题?提前感谢!
发布于 2017-07-20 20:17:41
sudo apt-get remove python3-matplotlib
然后使用传统的pip-way风格进行安装:sudo pip3 install matplotlib
此外,@Andy注意到该脚本不仅删除了matplotlib,还删除了seaborn。因此,您可能还需要使用pip安装它。
我试着按照@Bodhi94的建议去做,但是没有成功。然后我试着从Ubuntu中删除python3-matplotlib,它成功了。
有没有可能出现冲突?如果有的话,请告诉我。
发布于 2017-07-14 20:46:49
尝试使用以下命令重新安装matplotlib。
sudo pip install matplotlib --upgrade --ignore-installed six发布于 2017-09-03 21:59:39
我替换了所有相关的Python文件,如下所示:一旦我收到消息ImportError:没有名为'matplotlib.externals‘的模块
我做到了:导入纳米/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/init.py -我将“从matplotlib.externals导入六个”替换为“导入六个”。
直到出现错误。
从那时起就完美地工作了
https://stackoverflow.com/questions/45103248
复制相似问题