我正在使用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'
甚至尝试过安装套餐&#39;六&#39;没有任何帮助。 我的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中看到我作为新手
答案 0 :(得分:11)
我在使用Python 3.5的Ubuntu上运行时遇到了同样的问题。似乎cx_freeze
存在导入其他文件的库的问题。
导入Queue
和requests
一起为我工作,所以:
import requests
from multiprocessing import Queue
我不认为在urllib
中指定"packages": ["urllib", "requests"]
是必要的。
答案 1 :(得分:4)
有几个基于项目包的选项:
方法一:
答案:我解决了问题,我的问题是我的文件名为queue.py 目录
方法2: 队列位于多处理模块中:
from multiprocessing import Queue
方法3: 将点数从1.5.6更新为8.1.2
`sudo python -m pip install -U pip`
重新启动系统(如有必要,不知道,但只有在重新启动新版本的pip后才会出现) 方法4:
来自six.moves.queue导入队列//我不知道你如何导入六个包
答案 2 :(得分:2)
在setup.py中,UIImageView
也可以做到这一点。
答案 3 :(得分:1)
除了
from multiprocessing import Queue
我回滚到旧版本的cx_freeze:
pip install cx-freeze==4.3.3
此外,“请求”库在缺少“urllib3”模块时抱怨。我将其升级为 requests == 2.13.0 ,现在一切正常。
我在Win10上使用Python 3.4。希望这会有所帮助。