安装 matplotlib 后仍然没有名为 pylab 的模块 [已解决]

Still no module named pylab afther installing matplotlib [SOLVED]

提问人:Gresdel 提问时间:11/17/2023 最后编辑:Gresdel 更新时间:11/17/2023 访问量:49

问:

我安装了matplotlib,但收到有关pylab不存在的错误。

from pylab import *
Traceback (most recent call last):
  File "c:\users\arne_\mu_code\test.py", line 1, in <module>
    from pylab import *
ModuleNotFoundError: No module named 'pylab'
>>> 

为了清楚起见,这是安装 Matplotlib 后 Windows 中的 CMD

C:\Users\arne_>python -m pip install -U pip
Requirement already satisfied: pip in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (21.2.4)
Collecting pip
  Using cached pip-23.3.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.2.4
    WARNING: Value for bin_prefix does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
    distutils: C:\Users\arne_\AppData\Local\Programs\Mu Editor\Python\bin
    sysconfig: C:\Users\arne_\AppData\Local\Programs\Mu Editor\Python\Scripts
    WARNING: Additional context:
    user = False
    home = None
    root = None
    prefix = None
    Uninstalling pip-21.2.4:
      Successfully uninstalled pip-21.2.4
Successfully installed pip-23.3.1

C:\Users\arne_>python -m pip install -U matplotlib
Collecting matplotlib
  Downloading matplotlib-3.7.3-cp38-cp38-win_amd64.whl.metadata (5.8 kB)
Collecting contourpy>=1.0.1 (from matplotlib)
  Downloading contourpy-1.1.1-cp38-cp38-win_amd64.whl.metadata (5.9 kB)
Collecting cycler>=0.10 (from matplotlib)
  Downloading cycler-0.12.1-py3-none-any.whl.metadata (3.8 kB)
Collecting fonttools>=4.22.0 (from matplotlib)
  Downloading fonttools-4.44.3-cp38-cp38-win_amd64.whl.metadata (157 kB)
     ---------------------------------------- 157.7/157.7 kB 2.3 MB/s eta 0:00:00
Collecting kiwisolver>=1.0.1 (from matplotlib)
  Downloading kiwisolver-1.4.5-cp38-cp38-win_amd64.whl.metadata (6.5 kB)
Collecting numpy<2,>=1.20 (from matplotlib)
  Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl.metadata (5.6 kB)
Requirement already satisfied: packaging>=20.0 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (21.3)
Collecting pillow>=6.2.0 (from matplotlib)
  Downloading Pillow-10.1.0-cp38-cp38-win_amd64.whl.metadata (9.6 kB)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (2.8.2)
Collecting importlib-resources>=3.2.0 (from matplotlib)
  Downloading importlib_resources-6.1.1-py3-none-any.whl.metadata (4.1 kB)
Collecting zipp>=3.1.0 (from importlib-resources>=3.2.0->matplotlib)
  Downloading zipp-3.17.0-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: six>=1.5 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Downloading matplotlib-3.7.3-cp38-cp38-win_amd64.whl (7.5 MB)
   ---------------------------------------- 7.5/7.5 MB 10.9 MB/s eta 0:00:00
Downloading contourpy-1.1.1-cp38-cp38-win_amd64.whl (477 kB)
   ---------------------------------------- 477.9/477.9 kB 10.0 MB/s eta 0:00:00
Downloading cycler-0.12.1-py3-none-any.whl (8.3 kB)
Downloading fonttools-4.44.3-cp38-cp38-win_amd64.whl (1.5 MB)
   ---------------------------------------- 1.5/1.5 MB 10.4 MB/s eta 0:00:00
Downloading importlib_resources-6.1.1-py3-none-any.whl (33 kB)
Downloading kiwisolver-1.4.5-cp38-cp38-win_amd64.whl (56 kB)
   ---------------------------------------- 56.2/56.2 kB 3.1 MB/s eta 0:00:00
Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB)
   ---------------------------------------- 14.9/14.9 MB 11.3 MB/s eta 0:00:00
Downloading Pillow-10.1.0-cp38-cp38-win_amd64.whl (2.6 MB)
   ---------------------------------------- 2.6/2.6 MB 11.1 MB/s eta 0:00:00
Downloading zipp-3.17.0-py3-none-any.whl (7.4 kB)
Installing collected packages: zipp, pillow, numpy, kiwisolver, fonttools, cycler, importlib-resources, contourpy, matplotlib
Successfully installed contourpy-1.1.1 cycler-0.12.1 fonttools-4.44.3 importlib-resources-6.1.1 kiwisolver-1.4.5 matplotlib-3.7.3 numpy-1.24.4 pillow-10.1.0 zipp-3.17.0

C:\Users\arne_>pip install matplotlib
Requirement already satisfied: matplotlib in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (3.7.3)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (1.1.1)
Requirement already satisfied: cycler>=0.10 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (4.44.3)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (1.4.5)
Requirement already satisfied: numpy<2,>=1.20 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (1.24.4)
Requirement already satisfied: packaging>=20.0 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (21.3)
Requirement already satisfied: pillow>=6.2.0 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (10.1.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: importlib-resources>=3.2.0 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from matplotlib) (6.1.1)
Requirement already satisfied: zipp>=3.1.0 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from importlib-resources>=3.2.0->matplotlib) (3.17.0)
Requirement already satisfied: six>=1.5 in c:\users\arne_\appdata\local\programs\mu editor\python\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)

我错过了什么吗?

python windows matplotlib pip

评论

2赞 BigBen 11/17/2023
pylab一开始就被弃用了。.import matplotlib.pyplot as plt
0赞 Gresdel 11/17/2023
谢谢,将 import matplotlib.pyplot 作为 plt 而不是 import pylab 返回没有名为 matplotlib 的模块:(
0赞 Trenton McKinney 11/17/2023
我建议使用 Anaconda 发行版,它可能会让你的生活更轻松。所有包都作为预编译的二进制文件安装。软件包列表如果您使用的是 Anaconda,请不要使用 pip 来安装/删除 conda 生态系统中存在的包。用。仅当软件包不随 提供时才使用 。使用可能会破坏您的安装,因为并且不会以相同的方式管理依赖项。conda install packagepipconda installpippipconda
0赞 Trenton McKinney 11/17/2023
matplotlib 和许多其他包都包括在内。
1赞 Gresdel 11/17/2023
谢谢,这解决了它,通过从提示符运行它,我创建了一个文件夹,可以访问并将我的项目保存在我的计算机上,而不是云:D

答: 暂无答案