pyinstaller打包失败
利用pip install pyinstaller 显示安装pyinstaller4.0版本失败,然后自动安装成3.3.1版本再pycharm中更新也不行
用pyinstaller3.3.1把.py文件打包成.exe文件时就报错,在网上搜索后说有可能是python版本问题,我使用了python3.9和python3.6发现都不行,报一样的错误。
这是把.py打包后的显示:
(jk) E:\python3.6>pyinstaller -F E:\python3.6\hello.py
269 INFO: PyInstaller: 3.3.1
269 INFO: Python: 3.9.0
270 INFO: Platform: Windows-10-10.0.19041-SP0
271 INFO: wrote E:\python3.6\hello.spec
273 INFO: UPX is not available.
275 INFO: Extending PYTHONPATH with paths
['E:\\python3.6', 'E:\\python3.6']
275 INFO: checking Analysis
391 INFO: checking PYZ
391 INFO: Building PYZ because out00-PYZ.toc is non existent
393 INFO: Building PYZ (ZlibArchive) E:\python3.6\build\hello\out00-PYZ.pyz
Traceback (most recent call last):
File "E:\jk\Scripts\pyinstaller-script.py", line 33, in <module>
sys.exit(load_entry_point('PyInstaller==3.3.1', 'console_scripts', 'pyinstaller')())
File "e:\jk\lib\site-packages\PyInstaller\__main__.py", line 94, in run
run_build(pyi_config, spec_file, **vars(args))
File "e:\jk\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "e:\jk\lib\site-packages\PyInstaller\building\build_main.py", line 791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "e:\jk\lib\site-packages\PyInstaller\building\build_main.py", line 737, in build
exec(text, spec_namespace)
File "<string>", line 17, in <module>
File "e:\jk\lib\site-packages\PyInstaller\building\api.py", line 98, in __init__
self.__postinit__()
File "e:\jk\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
self.assemble()
File "e:\jk\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
self.code_dict = {
File "e:\jk\lib\site-packages\PyInstaller\building\api.py", line 129, in <dictcomp>
key: strip_paths_in_code(code)
File "e:\jk\lib\site-packages\PyInstaller\building\utils.py", line 624, in strip_paths_in_code
consts = tuple(
File "e:\jk\lib\site-packages\PyInstaller\building\utils.py", line 625, in <genexpr>
strip_paths_in_code(const_co, new_filename)
File "e:\jk\lib\site-packages\PyInstaller\building\utils.py", line 632, in strip_paths_in_code
return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
求各位大佬帮忙看一看
在 PyCharm 中重装下 pyinstaller 试试看
你在cmd里面下载pyinstaller:pip install pyinstaller
然后切到你要打包的那个文件的目录,用pyinstaller -D XXX.py或者pyinstaller -F XXX.py试试
有时候pycharm不行换个地方试试{:10_256:} Twilight6 发表于 2021-6-26 16:55
在 PyCharm 中重装下 pyinstaller 试试看
卸载了pyinstaller后还是不行,在pycharm中可以搜索到pyinstaller4.3的版本,但是下载后安装的还是3.3.1版本 飞翔的JK 发表于 2021-6-26 18:36
卸载了pyinstaller后还是不行,在pycharm中可以搜索到pyinstaller4.3的版本,但是下载后安装的还是3.3.1 ...
你先卸载,然后打开 PyCharm 中自带的命令行运行下面代码,试试看:
python -m pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple
学习中... 发表于 2021-6-26 17:36
你在cmd里面下载pyinstaller:pip install pyinstaller
然后切到你要打包的那个文件的目录,用pyinstaller ...
试过了,cmd中pyinstaller -F XXX.py后显示要安装pypiwin32,但是我pip install pypiwin32后,显示:
E:\python3.6>pip install pypiwin32
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pypiwin32 in c:\users\姜轲\appdata\roaming\python\python39\site-packages (223)
Requirement already satisfied: pywin32>=223 in c:\users\姜轲\appdata\roaming\python\python39\site-packages (from pypiwin32) (301)
已经安装了pypiwin32了,但是在运行pyinstller时依旧显示需要安装pypiwin32 Twilight6 发表于 2021-6-26 18:39
你先卸载,然后打开 PyCharm 中自带的命令行运行下面代码,试试看:
还是不行{:5_104:}{:5_104:}
一堆错误代码
WARNING: Discarding https://pypi.tuna.tsinghua.edu.cn/packages/3c/c9/c3f9bc64eb11eee6a824686deba6129884c8cbdf70e750661773b9865ee0/PyInstaller-3.
6.tar.gz#sha256=3730fa80d088f8bb7084d32480eb87cbb4ddb64123363763cf8f2a1378c1c4b7 (from https://pypi.tuna.tsinghua.edu.cn/simple/pyinstaller/) (r
equires-python:>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*). Command errored out with exit status 1: 'E:\jk\Scripts\python.exe' 'E:\jk\li
b\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\姜轲\AppData\Local\Temp\tmp_bz0gztu' Ch
eck the logs for full command output.
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e2/c9/0b44b2ea87ba36395483a672fddd07e6a9cb2b8d3c4a28d7ae76c7e7e1e5/PyInstaller-3.5.tar.
gz (3.5 MB)
|███████████████████████████████ | 3.4 MB 16 kB/s eta 0:00:08ERROR: Exception:
Traceback (most recent call last):
File "E:\jk\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
yield
File "E:\jk\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "E:\jk\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "C:\Program Files\Python39\lib\http\client.py", line 458, in read
n = self.readinto(b)
File "C:\Program Files\Python39\lib\http\client.py", line 502, in readinto
n = self.fp.readinto(b)
File "C:\Program Files\Python39\lib\socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "C:\Program Files\Python39\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "C:\Program Files\Python39\lib\ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\jk\lib\site-packages\pip\_internal\cli\base_command.py", line 180, in _main
status = self.run(options, args)
File "E:\jk\lib\site-packages\pip\_internal\cli\req_command.py", line 204, in wrapper
return func(self, options, args)
File "E:\jk\lib\site-packages\pip\_internal\commands\install.py", line 318, in run
requirement_set = resolver.resolve(
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 127, in resolve
result = self._result = resolver.resolve(
File "E:\jk\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 473, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "E:\jk\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 341, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File "E:\jk\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _merge_into_criterion
if not criterion.candidates:
File "E:\jk\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 139, in __bool__
return bool(self._sequence)
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 143, in __bool__
return any(self)
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 129, in <genexpr>
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 33, in _iter_built
candidate = func()
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 200, in _make_candidate_from_link
self._link_candidate_cache = LinkCandidate(
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 306, in __init__
super().__init__(
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 151, in __init__
self.dist = self._prepare()
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 234, in _prepare
dist = self._prepare_distribution()
File "E:\jk\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 317, in _prepare_distribution
return self._factory.preparer.prepare_linked_requirement(
File "E:\jk\lib\site-packages\pip\_internal\operations\prepare.py", line 508, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "E:\jk\lib\site-packages\pip\_internal\operations\prepare.py", line 550, in _prepare_linked_requirement
local_file = unpack_url(
File "E:\jk\lib\site-packages\pip\_internal\operations\prepare.py", line 239, in unpack_url
file = get_http_url(
File "E:\jk\lib\site-packages\pip\_internal\operations\prepare.py", line 102, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File "E:\jk\lib\site-packages\pip\_internal\network\download.py", line 157, in __call__
for chunk in chunks:
File "E:\jk\lib\site-packages\pip\_internal\cli\progress_bars.py", line 152, in iter
for x in it:
File "E:\jk\lib\site-packages\pip\_internal\network\utils.py", line 62, in response_chunks
for chunk in response.raw.stream(
File "E:\jk\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "E:\jk\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "C:\Program Files\Python39\lib\contextlib.py", line 135, in __exit__
self.gen.throw(type, value, traceback)
File "E:\jk\lib\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out.
飞翔的JK 发表于 2021-6-26 18:59
还是不行
一堆错误代码
WARNING: Discarding https://pypi.tuna.tsinghua.edu.cn/pa ...
下载超时了,重试一两次看看
Twilight6 发表于 2021-6-26 19:01
下载超时了,重试一两次看看
没成功,和在pycharm中安装一样,到最后显示只安装了pyinstaller3.3.1的版本 打包前准备, (版本 python 3.8.*)
下载安装 pyinstaller 在 Cmd 中 输入命令 pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple(如果失败了就再执行一次,一次,一次,肯定安的上)
直接用我的脚本打包:
import os
import traceback
from easygui import *
module = fileopenbox("选择需要打包的主模块")
icon = fileopenbox("选择图标") # 可以不选
os.system('pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple some-package')
all_module_path = (os.path.dirname(module),"C:\\Users\\Administrator\\Desktop\\Server-Data-Update")# 这里添加所有自写模块的路径的最外层文件夹路径,我写的这些可以删掉
dirs = ''
for each1 in all_module_path:
for each in os.listdir(each1):
path = os.path.join(each1,each)
if os.path.isdir(path):
dirs += path +';'
if icon:
os.system(f'pyinstaller -F {module} -p '+ dirs + f' -i {icon}')
else:
os.system(f'pyinstaller -F {module} -p '+ dirs)
然后把打包后的 exe 移动到主模块的路径。
页:
[1]