【问题标题】:Type Error 'module' is not callable - how to fix?类型错误“模块”不可调用 - 如何修复?
【发布时间】:2021-10-11 02:22:54
【问题描述】:

我检查了其他类似的问题,但它们不起作用。我正在尝试运行以下代码:

# Create the images

for n in progressbar(range(count)):
    
    # Set image name
    image_name = str(n).zfill(zfill_count) + '.png'
    
    # Get a random set of valid traits based on rarity weights
    trait_sets, trait_paths = generate_trait_set_from_config()
    # Generate the actual image
    generate_single_image(trait_paths, os.path.join(op_path, image_name))
    
    # Populate the rarity table with metadata of newly created image
    for idx, trait in enumerate(trait_sets):
        if trait is not None:
            rarity_table[CONFIG[idx]['name']].append(trait[: -1 * len('.png')])
        else:
            rarity_table[CONFIG[idx]['name']].append('none')**

我在“for n in progressbar”这一行收到错误消息。我看到过一些参考资料,可能我有多个同名的文件,但我找不到它们。

【问题讨论】:

  • 进度条的导入是什么?
  • progressbar() 是某种函数或模块,你能分享一下这是什么库吗?
  • progressbar 来自哪里?是进口吗?
  • 从 conda 我运行了“pip install Pillow pandas progressbar2”和 pip install progressbar

标签: python conda


【解决方案1】:

只有progressbar2可以在没有实例的情况下使用

pip uninstall progressbar
pip install progressbar2

示例代码

import time
from progressbar import progressbar

for i in progressbar(range(100)):
    time.sleep(0.02)

【讨论】:

    猜你喜欢
    • 2020-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多