Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

python - ImportError: No module named 'queue' while running my app freezed with cx_freeze

I am using python 3.4. I am able to run my python script without any problem. But While running my freezed python script , following error have appeared. I am able to freeze my script successfully too with cx_freeze.

C:Program Files (x86)utils>utils.exe
Traceback (most recent call last):
  File "C:Python34libsite-packages
equestspackages\__init__.py", line 27, i
n <module>
    from . import urllib3
  File "C:Python34libsite-packages
equestspackagesurllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "C:Python34libsite-packages
equestspackagesurllib3connectionpool.py", line 28, in <module>
    from .packages.six.moves.queue import LifoQueue, Empty, Full
  File "C:Python34libsite-packages
equestspackagesurllib3packagessix.py", line 203, in load_module
    mod = mod._resolve()
  File "C:Python34libsite-packages
equestspackagesurllib3packagessix.py", line 115, in _resolve
    return _import_module(self.mod)
  File "C:Python34libsite-packages
equestspackagesurllib3packagessix.py", line 82, in _import_module
    __import__(name)
ImportError: No module named 'queue'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:Python34libsite-packagescx_Freezeinitscripts\__startup__.py", line 12, in <module>
    __import__(name + "__init__")
  File "C:Python34libsite-packagescx_FreezeinitscriptsConsole.py", line 21, in <module>
    scriptModule = __import__(moduleName)
  File "utils.py", line 3, in <module>
  File "C:Python34libsite-packages
equests\__init__.py", line 63, in <module>
    from . import utils
  File "C:Python34libsite-packages
equestsutils.py", line 24, in <module>
    from ._internal_utils import to_native_string
  File "C:Python34libsite-packages
equests\_internal_utils.py", line 11, in <module>
    from .compat import is_py2, builtin_str
  File "C:Python34libsite-packages
equestscompat.py", line 11, in <module>
    from .packages import chardet
  File "C:Python34libsite-packages
equestspackages\__init__.py", line 29, in <module>
    import urllib3
  File "C:Python34libsite-packagesurllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "C:Python34libsite-packagesurllib3connectionpool.py", line 28, in <module>
    from .packages.six.moves.queue import LifoQueue, Empty, Full
  File "C:Python34libsite-packagesurllib3packagessix.py", line 203, in load_module
    mod = mod._resolve()
  File "C:Python34libsite-packagesurllib3packagessix.py", line 115, in _resolve
    return _import_module(self.mod)
  File "C:Python34libsite-packagesurllib3packagessix.py", line 82, in _import_module
    __import__(name)
ImportError: No module named 'queue'

Even tried installing package 'six' with no help. My setup.py is from cx_Freeze import setup, Executable import requests.certs

setup(
name = "utils" ,
version = "0.1" ,
description = " utils for accounts" ,
executables = [Executable("utils.py")],
options = {"build_exe": {"packages": ["urllib", "requests"],"include_files":[(requests.certs.where(),'cacert.pem')]}},

)

script imports following module

import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom

Any help will be highly appreciated. please see me as novice in python

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same issues running on Ubuntu with Python 3.5. It seems that cx_freeze has problems with libraries that import other files or something like that.

Importing Queue together with requests worked for me, so:

import requests
from multiprocessing import Queue

And I don't think specifying urllib in "packages": ["urllib", "requests"] is necessary.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...