《Python编程:从入门到实践》- 16章-16.2.5制作世界地图

import pygal 后报如标题的error

参考CSDN 解决:AttributeError: module 'pygal' has no attribute 'Worldmap' 问题

# from pygal_maps_world.i18n import COUNTRIES
import pygal wm = pygal.Worldmap() # 调用一个Worldmap实例
wm.title = 'North, Central, and South America' # 方法add():接受一个标签和一个列表,后者包含要突出的国家的国别码
# 每次调用add()将为指定的国家选择一种新颜色,并在图表左边显示该颜色和指定的标签
wm.add('North America', ['ca','mx','us'])
wm.add('Central America',['bz','cr','gt','hn','ni','pa','sv'])
wm.add('South America',['ar','bo','br','cl', 'co', 'ec', 'gf',
'gy', 'pe', 'py', 'sr', 'uy', 've']) wm.render_to_file('americas.svg') # NameError: name 'pygal' is not defined
# 错误位置:wm = pygal.Worldmap()
# 针对这个错误,尝试import pygal,后依然报错:
# AttributeError: module 'pygal' has no attribute 'Worldmap'

解决:

报错是因为之前的模块已经不存在了,需要将前两行代码代替为:

import pygal_maps_world.maps

wm = pygal_maps_world.maps.World()

再运行,问题解决

END

【问题解决方案】AttributeError: module 'pygal' has no attribute 'Worldmap'的更多相关文章

  1. 解决Pycharm更新package出现的问题:AttributeError:module 'pip' has no attribute 'main'

    很久一段时间没有更新Pycharm当中的package了,今天打开Pycharm点击package更新,发生了错误,AttributeError:module 'pip' has no attribu ...

  2. AttributeError: 'module' object has no attribute 'gfile'

    While running TensorFlow's classify_image, getting AttributeError: 'module' object has no attribute ...

  3. Python AttributeError: 'Module' object has no attribute 'STARTF_USESHOWINDOW'

    夫学须志也,才须学也,非学无以广才,非志无以成学.--诸葛亮 生活有度,自得慈铭 --杜锦阳 今天新来的同事安装环境遇到个莫名其妙的问题: AttributeError: 'Module' objec ...

  4. Intel发布神经网络压缩库Distiller:快速利用前沿算法压缩PyTorch模型——AttributeError: module ‘tensorboard' has no attribute 'lazy'

    转载自:CSDN Nine-days   近日,Intel 开源了一个用于神经网络压缩的开源 Python 软件包 Distiller,它可以减少深度神经网络的内存占用.加快推断速度及节省能耗.Dis ...

  5. AttributeError: module 'time' has no attribute 'clock'

    在python3.8中flask项目运行报错: AttributeError: module 'time' has no attribute 'clock'解决方案 主要原因是因为python3.8中 ...

  6. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  7. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  8. attributeError:'module' object has no attribute ** 解决办法

    写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...

  9. AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'

    /*************************************************************************** * AttributeError: 'modu ...

随机推荐

  1. DataIntegrityViolationException

    今天出现了这个问题: org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch upd ...

  2. 一次composer错误使用引发的思考

    一次composer错误使用引发的思考 这个思考源自于一个事故.让我对版本依赖重新思考了一下. 事故现象 一个线上的管理后台,一个使用laravel搭建的管理后台,之前在线上跑的好好的,今天comop ...

  3. qs.stringify和JSON.stringify的使用和区别

    qs可通过npm install qs命令进行安装,是一个npm仓库所管理的包. 而qs.stringify()将对象 序列化成URL的形式,以&进行拼接. JSON是正常类型的JSON,请对 ...

  4. GoLang simple-project-demo-02

    GoLang 有很多种数据类型:字符型,整型,浮点型,布尔型.下面是基础例子: package main import "fmt" func main() { fmt.Printl ...

  5. GoLang simple-project-demo-01

    Hello world 经典例子: package main import "fmt" func main(){ fmt.Println("hello world&quo ...

  6. ASP.Net Mvc实现自定义User Identity用户身份识别系统(2)

    上一篇博文中已经实现了如何在页面上使用自定义的属性即上篇博文所示的@this.U,今天将进一步研究用户自定义User Identity; 实现思路: 通过研究微软自带identity的套路,我们可以发 ...

  7. 《全栈营销之如何制作个人博客》之二:php环境安装及个人博客后台搭建 让你的博客跑起来

    上一节我们讲了个人博客用什么开发语言,用什么CMS系统,从这一节我们就开始真正的干货,这一节我们讨论一下PHP环境的安装,及个人博客后台的搭建,让你的博客在正常的PHP环境中运行起来,你就可以进行后台 ...

  8. Django之路由分发和反向解析

    一.路由分发: 路由分发是指:总路由不再直接做路由与视图函数的对应关系,而是将获取的路由分发给下面的app去处理对应关系 from django.conf.urls import url,includ ...

  9. Jinja2用法总结

    Jinja2用法总结   一:渲染模版 要渲染一个模板,通过render_template方法即可. @app.route('/about/') def about(): # return rende ...

  10. su和sudo的区别

    首先来说一下su 然后是sudo