《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. win10启动远程桌面连接的设置

    现在win10系统用的非常普遍,做项目的时候,也经常将一台win10系统的机器当作服务器使用.这就涉及到利用远程桌面登录到win10系统的问题,有几次利用远程桌面登录win10系统的设置经历,好像每次 ...

  2. ActivityJump+ActivityManager【Activity之间的跳转和Activity任务栈管理】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 封装Activity跳转的方法以及实现Activity任务栈管理. 效果图   代码分析 ActivityJump:封装Activi ...

  3. Flink从入门到放弃(入门篇4) DataStreamAPI

    戳更多文章: 1-Flink入门 2-本地环境搭建&构建第一个Flink应用 3-DataSet API 4-DataSteam API 5-集群部署 6-分布式缓存 7-重启策略 8-Fli ...

  4. Asp.NetCore轻松学-实现一个轻量级高可复用的RabbitMQ客户端

    前言 本示例通过对服务订阅的封装.隐藏细节实现.统一配置.自动重连.异常处理等各个方面来打造一个简单易用的 RabbitMQ 工厂:本文适合适合有一定 RabbitMQ 使用经验的读者阅读,如果你还没 ...

  5. jquery快速入门(三)

    捕获内容和属性 1.DOM 操作 获得内容 - text().html() 以及 val() text() - 设置或返回所选元素的文本内容,如果不带值则是返回值,如果带值则是修改值,如:$('p') ...

  6. json属性名必须加引号的讨论

    优质参考资料: 1.https://blog.csdn.net/Goskalrie/article/details/52151175 2.https://blog.csdn.net/weixin_42 ...

  7. Java集合类源码解析:Vector

    [学习笔记]转载 Java集合类源码解析:Vector   引言 之前的文章我们学习了一个集合类 ArrayList,今天讲它的一个兄弟 Vector.为什么说是它兄弟呢?因为从容器的构造来说,Vec ...

  8. MySQL优化面试

    原则:尽量使用整型表示字符串 存储IP INET_ATON(str),address to number INET_NTOA(number),number to address MySQL内部的枚举类 ...

  9. mysql生成日期的辅助表

    为了解决mysql按日期分组查询统计的时候,没有数据补0.可以生成连续的时间表格来辅助查询* 生成按天的数据 * 每一个小时为一个分段 生成如下辅助表 *代码如下 CREATE TABLE num ( ...

  10. js当地天气调用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...