Solved: SyntaxError of %matplotlib line magic: get_ipython().magic(‘matplotlib inline‘) error

Problem

在使用如下命令时出现 SyntaxError 报错,位置指向第二行的 %

import matplotlib
%matplotlib inline

google 之后在 github issure 上找到了一个 “解决方法”

from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'inline')

但是继续报错

AttributeError: 'NoneType' object has no attribute 'run_line_magic'

Solvement

解决后分析,当时作者的 matplotlib可能存在如下问题

  1. 版本老旧
  2. 作为前置包,在安装某些包的同时安装了 matplotlib(这些前置包可能存在问题)
  3. 使用了错误的 conda 安装命令

因此可以直接尝试用 pip 更新/ 重装该包

pip upgrade matplotlib
pip uninstall matplotlib
pip install matplotlib

如仍有问题,欢迎留言

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
The first computer programming book Iread was entitled Programming Windows 3.0by Charles Petzold. This was around the time when Microsoft Windows 3.0 (circa 1992) once and for all showed the industry that Microsoft was acompany with afuture. Writing code for Windows back then was complicated by many things: lack of documentation, 16-bit architecture, and the necessity of buying acompiler separate from the software development kit (SDK). Charles’s book tied everything together and solved the problem of how to write aprogram for Windows. Now the problems are quite the opposite: we have too much documentation, we have 64-bit architectures, and everything including the kitchen sink is thrown into adevelopment environment. Now we need to figure out what we actually need. We have too many options— too many ways to solve the same problem. What Iam trying to do with this book is the same thing that Charles did for me when Ifirst started out, and that was to help me figure out what Ineeded to write code. This book is about explaining the C# programming language in the context of solving problems. C# has become asophisticated programming language that can achieve many goals, but you are left wondering what techniques to use when. This book is here to answer your questions. This book is not areference to all of the features of the C# programming language. Idon’t explain the esoteric C# features. Istick to the C# programming features that you will use day in and day out. That does not mean that you will be missing certain C# programming language constructs, because Ihave covered all of the major features. To get the full benefit of this book, Isuggest that you do the exercises at the end of the chapters. The answers are available on the Apress web site (http://www.apress.com), and you can cheat and not do the exercises, but Iadvise against that. If you are abeginning programmer who has no clue about C#, and you read this book and do the exercises, Iam almost entirely sure that you will be asolid and knowledgeable C# pro- grammer by the end of the book. If that sounds like abig promise, well, yes it is. The chapter text is intended to get you acquainted with the C# programming language and how to apply its features. The exercises are intended to make sure you actually understand the C# programming language and its features. The chapter exercises are challenging. They cannot be solved within afew minutes. In fact, when Idid all of the exercises, it took me five working-hour days to do all of them! If you have any questions, such as, “So what was he trying to get at with that exercise?” Iam available on Skype with the user ID christianhgross. Please don’t just ring me. First chat using text, and if necessary, we can have avoice conversation. Also, you can send e-mail to me at [email protected]. Thanks and good luck.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

江湖留名

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值