You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Python脚本遇ImportError:无法导入'languages',已装iso639仍报错

解决ImportError: cannot import name 'languages'的问题

Hey there, let's troubleshoot this import error step by step. This issue almost always boils down to version mismatches or accidentally installing the wrong package. Here's what you can do:

1. Verify which iso639 package you have installed

First, check if you've got the correct package. There are a few packages on PyPI with similar names, but the most common one that includes the languages object is the original iso639 (not iso639-2 or iso639-3). Run this command to list your installed packages and their versions:

pip list | grep iso639

2. Downgrade or upgrade to a compatible version

The languages import was available in older versions of the iso639 package (like v0.4.5), but newer versions (v2.0.0+) restructured the library.

  • If you want to keep using from iso639 import languages, downgrade to a version that supports it:
    pip install iso639==0.4.5
    
  • If you prefer using the latest version, adjust your import statement to match the new structure. For the latest iso639 package, you'd import languages like this:
    from iso639.languages import languages
    # Or to access language data directly:
    from iso639 import Language
    

3. Uninstall conflicting packages

If you accidentally installed a different package with a similar name (like iso639-2), it might be overriding the correct iso639 package. Uninstall any conflicting packages first:

pip uninstall -y iso639 iso639-2 iso639-3
# Then reinstall the correct one
pip install iso639==0.4.5  # or the latest version if you adjust imports

4. Check your virtual environment (if using one)

Make sure you're running your script in the same virtual environment where you installed the iso639 package. Sometimes packages get installed globally instead of in your project's venv, leading to import errors.

内容的提问来源于stack exchange,提问作者NamesJoeyWheeler

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:16:57