Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller doesn't import Queue

I'm trying to compile some script with twisted and Queue.

pyinstaller sample.py --onefile
# -*- coding: utf-8 -*-#
from twisted import *
import queue as Queue
a = Queue.Queue()

Unfortunately, produced file fails with ImportError: No module named queue.

like image 548
Pavel M. Avatar asked Apr 04 '16 10:04

Pavel M.


1 Answers

I don't think this is a PyInstaller or Twisted related issue at all. The Queue module is part of the standard library, and the issue is how you're naming it. In Python 2, it's Queue with a capital letter, but in Python 3, it's renamed queue to follow the more standard naming convention where modules have lowercase names.

Your script seems like it's a port of Python 2 code to Python 3 (thus the as Queue part of the import), but you're running it with Python 2 still. That may fail in other more subtle ways than just the Queue import being wrong (e.g. its Unicode handling may be all wrong).

like image 135
Blckknght Avatar answered Oct 04 '22 23:10

Blckknght