首页 > 解决方案 > Type Error 'module' is not callable - how to fix?

问题描述

I have checked other questions similar but they are not working. I'm trying to run the following code:

# 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')**

I'm getting the error over the line "for n in progressbar". I've seen references that maybe I have multiple files named the same but I can't find them.

标签: pythonconda

解决方案


only progressbar2 can be used without a instance

pip uninstall progressbar
pip install progressbar2

sample code

import time
from progressbar import progressbar

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

推荐阅读