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

时间:2015-09-24 09:02:51

标签: python macos python-3.x

#!/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()
  

流程(28411)开始......   我(28411)刚刚创建了一个子进程(28412)。   我是孩子的过程(28412),我的父母是28411。   Traceback(最近一次调用最后一次):     文件“webApp.py”,第5行,in       导入asyncio,os,json,时间     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/init.py”,第21行,in   Traceback(最近一次调用最后一次):     文件“webApp.py”,第5行,in       导入asyncio,os,json,时间     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/init.py”,第21行,in       来自.base_events import *     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py”,第18行,in       来自.base_events import *     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/base_events.py”,第18行,in       import concurrent.futures     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/init.py”,第17行,in       import concurrent.futures     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/init.py”,第17行,in       来自concurrent.futures.process导入ProcessPoolExecutor     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/process.py”,第54行,       来自concurrent.futures.process导入ProcessPoolExecutor     文件“/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/concurrent/futures/process.py”,第54行,       来自多处理导入SimpleQueue       来自多处理导入SimpleQueue   ImportError:无法导入名称'SimpleQueue'   ImportError:无法导入名称'SimpleQueue'

1 个答案:

答案 0 :(得分:2)

simpleQueue的API似乎已经改变。

在python3.3中,它位于multiprocessing.SimpleQueue中(请参阅文档1

在python3.2中,它位于multiprocessing.queues.SimpleQueue中(请参阅文档2

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