没有名为 'Queue' 的模块

No module named 'Queue'

我导入了 Python 个模块

import Queue
from threading import Thread
import time

但是当我运行代码

File "b1.py", line 3, in <module>
    import Queue
ModuleNotFoundError: No module named 'Queue'

我在 SO 上看到过类似的帖子,但对我来说没什么用

/usr/bin/python3 --version
Python 3.5.2
milenko@milenko-System-Product-Name:~$ python --version
Python 3.6.0 :: Anaconda custom (64-bit)

如果我改成

from multiprocessing import Queue

没有进口problem.But比我有这个

AttributeError: 'Queue' object has no attribute 'join'

接下来我应该尝试什么?

在 Python 2 上,模块命名为 Queue,在 Python 3 上,它 was renamed to follow PEP8 guidelines(模块名称全部小写),使其成为 queue. class 在所有版本(PEP8 之后)上保持 Queue

通常,您编写版本可移植导入的方式是:

try:
    import queue           # Python 3 import
except ImportError:
    import Queue as queue  # If queue missing, we're on Py2, import Py2 as Py3 name

就我而言,Python 2.7

有以下内容
from Queue import Queue, Empty

我只将模块名称更改为小写,它与 Python 3 like

一起工作正常
from queue import Queue, Empty