jupyter notebook import error: no module named 'matplotlib'

后端 未结 7 1793
小鲜肉
小鲜肉 2021-01-02 06:50

I\'m an ubuntu 16.4 user and I installed anaconda3 and using both python2 and python3 kernels.

>>>jupyter kernelspec list Available kernels: pyt

7条回答
  •  萌比男神i
    2021-01-02 07:17

    In my case, the matplotlib conda pkg was corrupted.

    conda list
    

    First, identify all the matplotlib pkgs installed in your environment. In my case, there were 2 pkgs.

    matplotlib

    matplotlib-base

    Now remove those using conda.

    conda remove matplotlib
    conda remove matplotlib-base
    

    Now check the list again to make sure, all the pkgs removed successfully. Then reinstall them again.

    conda install matplotlib
    conda install matplotlib-base
    

    You may encounter an error saying

    SafetyError: The package for matplotlib-base located at /home//anaconda3/pkgs/matplotlib-base-3.1.3-py37hef1b27d_0 appears to be corrupted. The path 'lib/python3.7/site-packages/matplotlib-3.1.3-py3.7-nspkg.pth' has an incorrect size. reported size: 569 bytes actual size: 570 bytes
    

    Now you need to remove this corrupted folder, in my case, "matplotlib-base-3.1.3-py37hef1b27d_0".

    Then try installing the pkgs again. It's better to run

    conda remove matplotlab
    

    again before reinstalling, to make sure anything left of those pkgs completely wiped out.

提交回复
热议问题