2014-05-08 16 views
0

我编写了一个非常简单的程序来演示多处理队列。但是,创建队列时会引发错误。创建多处理队列会引发错误

import multiprocessing as mp 
q = mp.Queue() #error right here 
q.put(1) 
print(q.get()) 

我收到此消息。

Traceback (most recent call last): 
    File "C:\Users\User\Documents\python\mptest.py", line 2, in <module> 
    q = mp.Queue() 
    File "C:\Python33\lib\multiprocessing\__init__.py", line 200, in Queue 
    from multiprocessing.queues import Queue 
    File "C:\Python33\lib\multiprocessing\queues.py", line 22, in <module> 
    from multiprocessing.connection import Pipe 
    File "C:\Python33\lib\multiprocessing\connection.py", line 21, in <module> 
    import tempfile 
    File "C:\Python33\lib\tempfile.py", line 35, in <module> 
    from random import Random as _Random 
ImportError: cannot import name Random 

我从来没有见过这种情况发生,谷歌搜索没有结果。它只发生在从命令行运行时。它在IDLE中运行得非常好。我正在使用Python 3.3.2。

+0

你粘贴了整个代码吗?因为它说你输入了不存在的Random。代码在cmd行以及ide中工作正常 – fscore

+0

@fscore是的。这让我感到困惑。 – Daffy

+0

你的代码有什么叫做import random? – fscore

回答

0

我认为它更多的是与安装的python版本有关。我在cmd行以及IDE上尝试了您的代码,但没有发现任何错误。我安装了python 2.7和3.2。但只是为了复制你的问题,我安装了3.3.2。我也遇到了同样的错误,因为我可能也有random.py文件。