Why can't I import COUNTRIES from pygal.i18n
Asked Answered
B

4

16

I'm trying to import COUNTRIES from pygal.i18n by using the piece of code below.

     from pygal.i18n import COUNTRIES

After I run this, I get the following error.

    ImportError: No module named 'pygal.i18n'.

Can anyone tell me what the problem is?

Thanks

Brundisium answered 3/3, 2016 at 11:27 Comment(0)
S
28

The i18n module was removed in pygal-2.0.0, however, it can now be found in the pygal_maps_world plugin.

You can install that with pip install pygal_maps_world. Then you can access COUNTRIES as pygal.maps.world.COUNTRIES:

from pygal.maps.world import COUNTRIES

Whats left of the i18n module can be imported with:

from pygal_maps_world import i18n
Slovene answered 3/3, 2016 at 12:18 Comment(3)
Thanks so much! However I was able to use "from pygal_maps_world.i18n import COUNTRIES".Brundisium
@HelpMe: that would work too! Can I direct you to stackoverflow.com/help/someone-answers and stackoverflow.com/help/accepted-answer for info on how to handle answers.Slovene
For those working through the book Python Crash Course you can also get specific instructions for updating the pygal code here: ehmatthes.github.io/pcc/chapter_16/README.htmlLampert
M
0

try: pip3 install pygal.maps.world and then: from pygal.maps.world import COUNTRIES

it does the same thing as i18n module

author, hope it worked for you

Mexican answered 21/1, 2020 at 9:25 Comment(0)
P
0
from pygal_maps_world import i18n

# выводим код страны и ее название в принятом международном формате
for country_code in sorted(i18n.COUNTRIES.keys()):
    print(f"{country_code} - {i18n.COUNTRIES[country_code]}")

For example, th - Thailand tj - Tajikistan tl - Timor-Leste tm - Turkmenistan

Pneumato answered 29/5, 2020 at 13:12 Comment(0)
P
0

I had the same problem, and this code worked:

from pygal_maps_world.i18n import COUNTRIES 
for country_code in sorted(COUNTRIES.keys()):
        print(country_code, COUNTRIES[country_code])
Pitiful answered 20/8, 2022 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.