ImportError: cannot import name 'languages'

5.9k Views Asked by At

I am trying to run a python script, but I get this error:

from iso639 import languages 
ImportError: cannot import name 'languages'

I have installed iso639, but I still get this error.

Any ideas how to fix this?

Was there something else I had to install?

1

There are 1 best solutions below

1
On BEST ANSWER

There are 2 similarly named packages:

You can check each package's PyPi and Github page to confirm which one you need.

But it seems what you are looking for is the iso-639 package (with the hyphen). Because its __init.py__ file has an importable languages module:

"""
Python library for ISO 639 standard
Copyright (c) 2014-2016 Mikael Karlsson (CSC - IT Center for Science Ltd.).
Licensed under AGPLv3.
"""

from __future__ import absolute_import
from iso639.iso639 import Iso639

__version__ = '0.4.5'
languages = Iso639()

So make sure to install iso-639

$ python3 -m pip install iso-639
...
Installing collected packages: iso-639
Successfully installed iso-639-0.4.5
$ python3
...
>>> import iso639
>>> dir(iso639)
[... 'iso639', 'languages']
>>> from iso639 import languages
>>> 

(Make sure to uninstall the other one, because both are imported as from iso639).