Python 期货问题

Python 期货问题,python,concurrent.futures,modulenotfounderror,Python,Concurrent.futures,Modulenotfounderror,所以我有一段代码需要使用Concurrent.futures模块,出于某种原因,它告诉我它不存在。我查过了,找不到问题所在。我试着从it安装我需要的工具,我想是这样的,但我只能下载其中一个。 错误消息: 从concurrent.futures导入ProcessPoolExecutor ModuleNotFoundError:没有名为“concurrent.futures”的模块; “并发”不是一个包 我的代码: import requests, time from concurrent.futu

所以我有一段代码需要使用Concurrent.futures模块,出于某种原因,它告诉我它不存在。我查过了,找不到问题所在。我试着从it安装我需要的工具,我想是这样的,但我只能下载其中一个。 错误消息:

从concurrent.futures导入ProcessPoolExecutor ModuleNotFoundError:没有名为“concurrent.futures”的模块; “并发”不是一个包

我的代码:

import requests, time
from concurrent.futures import ProcessPoolExecutor

sites = ["http://www.youtube.com"]

def get_one(site):
    resp = requests.get(site)
    size = len(resp.content)
    print(f"download {site} bytes from {site}")
    return size

def main():
    total_size = 0
    start = time.perf_counter()
    with ProcessPoolExecutor as exec:
        total_size = sum(exec.map(get_one, sites))
    end = time.perf_counter()
    for site in sites:
        
        total_size += size
        #print(f"downlded {size} bytes from {site}")
    #end = time.perf_counter()
    
    print(f"elapsed time: {end - start} seconds")
    print (f"downloaded a totla of {total_size} bytes")
    
    
if __name__== "__main__":
    main()

我知道通常当我说“from”时应该有一个文件,但我查找的所有内容都是concurrent.futures是python的一部分,但由于某种原因,我的文件不能正常工作。如果它在那里,我必须安装它吗?

我发现我的文件夹中有一个名为concurrent.py的文件,它把一切都搞砸了

如果进入终端,运行python-v,然后键入import concurrent,你会看到类似这样的东西,
#code对象来自'/opt/anaconda3/lib/python3.8/concurrent/uu pycache\uuuu/u init\uuuuuu.cpython-38.pyc'import'concurrent'.
你能检查一下吗?