导入matplotlib.pyplot在原子edi中

2024-10-01 15:44:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用pyzo运行python脚本。但是我觉得需要切换到Atom代码编辑器。我可以毫无问题地运行python脚本。在

有一次我需要使用库matplotlib。在pyzo我会做:

import matplotlib.pyplot as plt

但它在原子里不起作用 enter image description here

错误消息:

Traceback (most recent call last): File "C:\Users\ivanl\Desktop\python trade\matplotlib.py", line 1, in import matplotlib.pyplot as plt File "C:\Users\ivanl\Desktop\python trade\matplotlib.py", line 1, in import matplotlib.pyplot as plt ImportError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package

在哪里安装matplotlib?为什么它在pyzo上工作而不是在atom上?在


Tags: inpyimport脚本matplotlibaslineplt
1条回答
网友
1楼 · 发布于 2024-10-01 15:44:05

来自The Module Search Path。在

When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then searches for a file named spam.py in a list of directories given by the variable sys.path. sys.path is initialized from these locations:

  • the directory containing the input script (or the current directory).
  • PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH).
  • the installation-dependent default.

这意味着您应该避免使用与标准库相同的名称或内置的模块名称命名模块。在

所以应该重命名脚本文件,而不是matplotlib.py。在

相关问题 更多 >

    热门问题