python3 错误,无法导入名称'SimpleQueue'


#!/usr/bin/env python3
import logging; logging.basicConfig(level=logging.INFO)
import asyncio, os, json, time
from datetime import datetime
from aiohttp import web
def index(request):
    return web.Response(body=b'<h1>Awesome</h1>')
@asyncio.coroutine
def init(loop):
    app = web.Application(loop=loop)
    app.router.add_route('GET', '/', index)
    srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 9000)
    logging.info('server started at http://127.0.0.1:9000...')
    return srv
loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()

Process (28411) start…I(28411)刚刚创建了一个子进程(28412)。我是子进程(28412),父进程是28411。回溯(最近一次调用):文件"webApp.py",第5行导入asyncio, os, json, time文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/init.py",在回溯(最近一次调用):文件"webApp.py",第5行导入asyncio, os, json, time文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/init.py",在从.base_events导入*文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py",第18行从.base_events导入*文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py",第18行进口concurrent.futures文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/init.py",第17行进口concurrent.futures文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/init.py",第17行从concurrent.futures.process中导入ProcessPoolExecutor文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/process.py",在从concurrent.futures.process中导入ProcessPoolExecutor文件"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/process.py",在从多进程中导入SimpleQueue从多进程中导入SimpleQueue无法导入名称"SimpleQueue"importterror:无法导入名称"SimpleQueue"

simpleQueue的API似乎发生了变化。

在python3.3中,它可以在multiprocessing.SimpleQueue中找到(参见文档1)

在python3.2中,它可以在multiprocessing.queues.SimpleQueue中找到(参见文档2)

您可能运行的python版本低于3.2,但代码是为新版本(>= 3.3)编写的。您可以尝试修改库以使用旧的导入或升级您的python版本。

最新更新