Python 导入错误:无法导入名称';ProcessPoolExecutor';从';concurrent.futures.process';

Python 导入错误:无法导入名称';ProcessPoolExecutor';从';concurrent.futures.process';,python,jupyter-notebook,pycharm,concurrent.futures,Python,Jupyter Notebook,Pycharm,Concurrent.futures,我有一个问题,我不知道发生了什么: 我尝试使用以下代码学习多处理教程: import concurrent.futures import time start = time.perf_counter() def do_something(seconds): print(f'sleeping {seconds} second(s)...') time.sleep(seconds) return 'Done sleeping' with concurrent.futur

我有一个问题,我不知道发生了什么: 我尝试使用以下代码学习多处理教程:

import concurrent.futures
import time

start = time.perf_counter()

def do_something(seconds):
    print(f'sleeping {seconds} second(s)...')
    time.sleep(seconds)
    return 'Done sleeping'

with concurrent.futures.ProcessPoolExecutor() as executor:
    f1 = executor.submit(do_something, 1)
    print(f1.result()) 
我在jupyter笔记本中成功运行了这段代码,但在Pycharm中运行时收到以下错误消息:

/Users/jiangxu/PycharmProjects/Assign_隔间/venv/bin/python/Users/jiangxu/PycharmProjects/Assign_隔间/multiprocessing.py
回溯(最近一次呼叫最后一次):
文件“/Users/jiangxu/PycharmProjects/Assign_隔间/multiprocessing.py”,第14行,在
以concurrent.futures.ProcessPoolExecutor()作为执行器:
文件“/usr/local/cillar/python/3.7.5/Frameworks/python.framework/Versions/3.7/lib/python3.7/concurrent/futures/__init___.py”,第43行,位于__
from.process导入ProcessPoolExecutor作为pe
文件“/usr/local/ceral/python/3.7.5/Frameworks/python.framework/Versions/3.7/lib/python3.7/concurrent/futures/process.py”,第53行
将多处理作为mp导入
文件“/Users/jiangxu/PycharmProjects/Assign_隔间/multiprocessing.py”,第14行,在
以concurrent.futures.ProcessPoolExecutor()作为执行器:
文件“/usr/local/cillar/python/3.7.5/Frameworks/python.framework/Versions/3.7/lib/python3.7/concurrent/futures/__init___.py”,第43行,位于__
from.process导入ProcessPoolExecutor作为pe
ImportError:无法从“concurrent.futures.process”(/usr/local/ceral/python/3.7.5/Frameworks/python.framework/Versions/3.7/lib/python3.7/concurrent/futures/process.py)导入名称“ProcessPoolExecutor”
进程已完成,退出代码为1

发生了什么事?

我也有同样的问题。这是因为python文件的名称是“multiprocessing”,所以您要做的就是更改它