Hello i have a big problem, i want to import queue but i get this message, somehow it dont exist.

Traceback (most recent call last):
File "D:\Python26\test.py", line 9, in <module>
import queue
ImportError: No module named queue

isnt that strange.

I have more problems..somehow you must write
from Queue import Queue

then i use this code

from Queue import Queue
def main():

    q = Queue.Queue()....

Traceback (most recent call last):
File "D:\Python26\test.py", line 166, in <module>
main()
File "D:\Python26\test.py", line 19, in main
q = Queue.Queue()
AttributeError: class Queue has no attribute 'Queue'

im lost

First off, I would just import Queue, rather then just that one method.
Second, Queue needs a max size value.
To do a queue, it should look like this, though I have never used it.

import Queue
q = Queue.Queue(5)
do_something(item_in_queue)
q.task_done(number of task)

I got this off of the documents online, so you should check there first.

Hello i have a big problem, i want to import queue but i get this message, somehow it dont exist.

Traceback (most recent call last):
File "D:\Python26\test.py", line 9, in <module>
import queue
ImportError: No module named queue

isnt that strange.

Module Queue has been renamed queue starting with Python3 to better reflect the fact that there are several queue classes (lifo, fifo, priority) in the module.

Are you sure you want to use Queue/queue or the double ended dequeue in module collections? This would behave more like a doubly linked list.

First off, I would just import Queue, rather then just that one method.
Second, Queue needs a max size value.
To do a queue, it should look like this, though I have never used it.

import Queue
q = Queue.Queue(5)
do_something(item_in_queue)
q.task_done(number of task)

I got this off of the documents online, so you should check there first.

the problem is that import queue and import Queue dont work..i get same faulr message....that the module dont exist.

Module Queue has been renamed queue starting with Python3 to better reflect the fact that there are several queue classes (lifo, fifo, priority) in the module.

Are you sure you want to use Queue/queue or the double ended dequeue in module collections? This would behave more like a doubly linked list.

I dont know enough python to be able to answer that, i use python 2.6 or something

the problem is that import queue and import Queue dont work

In your original example, Queue imported fine. It was the statement calling Queue that was the problem. Try the first two lines of redyugi's example and see what you get.

from Queue import Queue   ##<----- imports fine
def main():
 
   ##=========================================================
   ## line 19 (here) is the problem
    q = Queue.Queue()....

Traceback (most recent call last):
File "D:\Python26\test.py", line 166, in <module>
main()
##=========================================================
## line 19 (here) is the problem
File "D:\Python26\test.py", line 19, in main
q = Queue.Queue()
AttributeError: class Queue has no attribute 'Queue'

Hmm, i still dont understand were the fault is, i must be tired.

if you do
from Queue import Queue

you only need to do
q = Queue()

if you do
from Queue import Queue

you only need to do
q = Queue()

ahh ok, i try that, thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.