python – ImportError:在使用cx_freeze运行我的应用程序时没有名为’queue’的模块
作者:互联网
我正在使用python 3.4.我能够毫无问题地运行我的python脚本.
但是在运行我的freezed python脚本时,出现了以下错误.
我也可以使用cx_freeze成功冻结我的脚本.
C:\Program Files (x86)\utils>utils.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 27, i
n <module>
from . import urllib3
File "C:\Python34\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.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:\Python34\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 21, in <module>
scriptModule = __import__(moduleName)
File "utils.py", line 3, in <module>
File "C:\Python34\lib\site-packages\requests\__init__.py", line 63, in <module>
from . import utils
File "C:\Python34\lib\site-packages\requests\utils.py", line 24, in <module>
from ._internal_utils import to_native_string
File "C:\Python34\lib\site-packages\requests\_internal_utils.py", line 11, in <module>
from .compat import is_py2, builtin_str
File "C:\Python34\lib\site-packages\requests\compat.py", line 11, in <module>
from .packages import chardet
File "C:\Python34\lib\site-packages\requests\packages\__init__.py", line 29, in <module>
import urllib3
File "C:\Python34\lib\site-packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Python34\lib\site-packages\urllib3\connectionpool.py", line 28, in <module>
from .packages.six.moves.queue import LifoQueue, Empty, Full
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python34\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
ImportError: No module named 'queue'
甚至尝试在没有帮助的情况下安装包’六’.
我的setup.py是
来自cx_Freeze导入设置,可执行文件
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')]}},
)
脚本导入以下模块
import requests
import urllib.request
import uuid
import json
import http.client
from xml.dom import minidom
任何帮助将受到高度赞赏.请在python中看到我作为新手
解决方法:
我在使用Python 3.5的Ubuntu上运行时遇到了同样的问题.似乎cx_freeze对导入其他文件的库有问题.
导入队列以及为我工作的请求,所以:
import requests
from multiprocessing import Queue
我不认为在“packages”中指定urllib:[“urllib”,“requests”]是必要的.
标签:python-3-4,python,import,cx-freeze 来源: https://codeday.me/bug/20191002/1843507.html