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

调用countrycode包报错TypeError: 'module' object is not callable求助

解决countrycode包调用报错TypeError: 'module' object is not callable
  • 核心错误原因:混淆了模块名与函数名,直接调用模块导致报错。该包的正确调用入口是模块内的convert函数,而非模块本身。
  • 修正后的测试代码:
from countrycode import convert
convert(codes=['Algeria', 'United States'], origin='country_name', target='iso3c')

也可采用另一种导入方式:

import countrycode
countrycode.convert(codes=['Algeria', 'United States'], origin='country_name', target='iso3c')
  • 关于临时文件找不到的问题:该文件是Spyder的ipykernel运行代码时生成的临时缓存文件,执行后会自动清理,找不到属于正常现象,无需关注,解决上述调用错误即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 09:45:35