无法导入pygal_maps_world.World [英] Can't import pygal_maps_world.World

查看:435
本文介绍了无法导入pygal_maps_world.World的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个简单的程序,以便使用 Pygal_maps_world 显示中美洲及其人口的地图。相同的代码如下:

I am trying to create a simple program so as to display the map of Central America with its population using Pygal_maps_world. Here's the code for the same:

import pygal_maps_world as pa

wm=pa.World()

wm.title="Map of Central America"
wm.add('North America',{'cd': 84949494949,'mx': 494794164,'us': 99794616})

wm.render_to_file('map.svg')

我尝试了几种有关导入世界地图的组合,以使其正常工作,但无济于事,我没有

I have tried a few combinations regarding the importing of the World maps to work properly but to no avail and I am not able to create the visualization.

推荐答案

在pygal的最新版本中,您从以下代码的前四行开始:

In the recent versions of pygal, you start with the first four lines of this code:

from pygal.maps.world import World

wm = World()
wm.force_uri_protocol = 'http'

wm.title="Map of Central America"
wm.add('North America',{'ca': 84949494949,'mx': 494794164,'us': 99794616})

wm.render_to_file('map.svg')

当我使用前四行和其余​​代码时,您的代码将运行,并且突出显示美国和墨西哥,但是突出显示刚果民主共和国而不是加拿大。将国家/地区代码更改为加拿大的 ca!这样,当然现在显示的是北美而非中美洲,因此请更改标题或更改国家/地区代码。

When I use those first four lines and the rest of your code, your code runs and it highlights the United States and Mexico, but it highlights the Democratic Republic of the Congo rather than Canada. Change the country code to 'ca' for Canada! This then, of course, now shows North America rather than central America, so either change your title or change your country codes.

这篇关于无法导入pygal_maps_world.World的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆