[英]Unable to import 'matplotlib.pyplot' without conda
I understand that a very similar question has been asked before, but the answer to said question was given in the context of anaconda, which did not help me as I am not familiar with anaconda.我知道以前曾问过一个非常相似的问题,但该问题的答案是在 anaconda 的上下文中给出的,这对我没有帮助,因为我不熟悉 anaconda。 Anyhow:
无论如何:
I'm trying to get started with tensorflow in visual studio code, but when I try to type the following:我正在尝试在 Visual Studio 代码中开始使用 tensorflow,但是当我尝试输入以下内容时:
import matplotlib.pyplot as plt
I get this error: Unable to import 'matplotlib.pyplot'
(along with pylint(import-error) in grayed-out text).我收到此错误:
Unable to import 'matplotlib.pyplot'
(以及灰显文本中的 pylint(import-error))。
How do I resolve this error without using anaconda?如何在不使用 anaconda 的情况下解决此错误? If the answer relates to typing something into a terminal, please specify where the command is supposed to be typed in, as part of why I can't figure this out is because online solutions never specify where a command should go.
如果答案与在终端中输入内容有关,请指定应该在哪里输入命令,作为我无法弄清楚的部分原因是因为在线解决方案从不指定命令应该在哪里 go。 Thanks!
谢谢!
I recommend getting familiar with the basic concepts of Python first.我建议先熟悉 Python 的基本概念。 From the different versions (Python 2.7, Python 3.x), the structure (libraries), and good practices (use virtual environments to sandbox your structure).
来自不同版本(Python 2.7、Python 3.x)、结构(库)和良好实践(使用虚拟环境对结构进行沙箱处理)。
pip
(which may install Python2.7 or Python3.x libraries, depending on what you default Python is or in what virtual environment you are currently working).pip
安装(可能安装 Python2.7 或 Python3.x 库,具体取决于您的默认 ZA7F5F35426B927411FC9231B56382173 您当前的工作环境).Z Anyway, open up a command prompt (as you haven't specified your system, I assume windows. => open PowerShell or cmd).无论如何,打开一个命令提示符(因为你没有指定你的系统,我假设 windows。=> 打开 PowerShell 或 cmd)。
pip3 install matplotlib
This installs the library matplotlib in the root environment.这会在根环境中安装库 matplotlib。 If you have an environment, activate it before issuing this command.
如果您有环境,请在发出此命令之前激活它。
I strongly recommend reading an introduction to Python to get a better overview of the concept of Python.我强烈建议阅读 Python 的介绍,以更好地了解 Python 的概念。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.