当前位置:网站首页>5.4 Pyinstaller库安装与使用
5.4 Pyinstaller库安装与使用
2022-07-23 05:43:00 【亲自巡山的大王】
Pyinstaller库:将.py源代码封装成可执行文件
Pyinstaller库使用
在.py文件目录下使用cmd命令
生成可执行文件命令
pyinstaller -F xx.py

清理打包临时文件
pyinstaller --clean xx.py
指定打包程序的图标文件icon
pyinstaller -i <图标文件名.ico> -F xx.py

Pyinstaller库安装
pip install pyinstaller
报错
Collecting pyinstaller
Downloading pyinstaller-5.2-py3-none-win32.whl (1.1 MB)
|▌ | 20 kB 8.8 kB/s eta 0:02:05ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
yield
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\http\client.py", line 464, in read
s = self.fp.read(amt)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\socket.py", line 705, in readinto
return self._sock.recv_into(b)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\ssl.py", line 1273, in recv_into
return self.read(nbytes, buffer)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\ssl.py", line 1129, in read
return self._sslobj.read(len, buffer)
TimeoutError: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
status = self.run(options, args)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\cli\req_command.py", line 203, in wrapper
return func(self, options, args)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\commands\install.py", line 315, in run
requirement_set = resolver.resolve(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
result = self._result = resolver.resolve(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 472, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 341, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
if not criterion.candidates:
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
return bool(self._sequence)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 140, in __bool__
return any(self)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 128, in <genexpr>
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 32, in _iter_built
candidate = func()
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 204, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 295, in __init__
super().__init__(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__
self.dist = self._prepare()
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 227, in _prepare
dist = self._prepare_distribution()
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 305, in _prepare_distribution
return self._factory.preparer.prepare_linked_requirement(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\operations\prepare.py", line 508, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\operations\prepare.py", line 550, in _prepare_linked_requirement
local_file = unpack_url(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\operations\prepare.py", line 239, in unpack_url
file = get_http_url(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\operations\prepare.py", line 102, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\network\download.py", line 145, in __call__
for chunk in chunks:
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\cli\progress_bars.py", line 144, in iter
for x in it:
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_internal\network\utils.py", line 63, in response_chunks
for chunk in response.raw.stream(
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 512, in read
with self._error_catcher():
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\lib\contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\Users\kai\AppData\Local\Programs\Python\Python310-32\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='files.pythonhosted.org', port=443): Read timed out.
WARNING: You are using pip version 21.2.3; however, version 22.1.2 is available.
You should consider upgrading via the 'C:\Users\kai\AppData\Local\Programs\Python\Python310-32\python.exe -m pip install --upgrade pip' command.
解决办法
python -m pip install -U pip
Requirement already satisfied: pip in c:\users\kai\appdata\local\programs\python\python310-32\lib\site-packages (21.2.3)
Collecting pip
Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 111 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.2.3
Uninstalling pip-21.2.3:
Successfully uninstalled pip-21.2.3
Successfully installed pip-22.1.2
pip install pyinstaller
Requirement already satisfied: pip in c:\users\kai\appdata\local\programs\python\python310-32\lib\site-packages (21.2.3)
Collecting pip
Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 111 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.2.3
Uninstalling pip-21.2.3:
Successfully uninstalled pip-21.2.3
Successfully installed pip-22.1.2
C:\Users\kai>pip install pyinstaller
Collecting pyinstaller
Downloading pyinstaller-5.2-py3-none-win32.whl (1.1 MB)
---------------------------------------- 1.1/1.1 MB 25.5 kB/s eta 0:00:00
Requirement already satisfied: setuptools in c:\users\kai\appdata\local\programs\python\python310-32\lib\site-packages (from pyinstaller) (57.4.0)
Collecting pywin32-ctypes>=0.2.0
Downloading pywin32_ctypes-0.2.0-py2.py3-none-any.whl (28 kB)
Collecting pefile>=2022.5.30
Downloading pefile-2022.5.30.tar.gz (72 kB)
---------------------------------------- 72.9/72.9 kB 18.8 kB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting altgraph
Downloading altgraph-0.17.2-py2.py3-none-any.whl (21 kB)
Collecting pyinstaller-hooks-contrib>=2021.4
Downloading pyinstaller_hooks_contrib-2022.8-py2.py3-none-any.whl (239 kB)
---------------------------------------- 239.8/239.8 kB 11.5 kB/s eta 0:00:00
Collecting future
Downloading future-0.18.2.tar.gz (829 kB)
---------------------------------------- 829.2/829.2 kB 21.8 kB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for pefile, since package 'wheel' is not installed.
Using legacy 'setup.py install' for future, since package 'wheel' is not installed.
Installing collected packages: pywin32-ctypes, altgraph, pyinstaller-hooks-contrib, future, pefile, pyinstaller
Running setup.py install for future ... done
Running setup.py install for pefile ... done
Successfully installed altgraph-0.17.2 future-0.18.2 pefile-2022.5.30 pyinstaller-5.2 pyinstaller-hooks-contrib-2022.8 pywin32-ctypes-0.2.0
边栏推荐
- Six trends and eight technologies of high-performance computing in data centers under "data center white paper 2022" and "computing from the east to the west"
- 钢结构基本原理复习
- ARM架构与编程3--按键控制LED(基于百问网ARM架构与编程教程视频)
- 钢结构基本原理试题及答案
- NLP natural language processing - Introduction to machine learning and natural language processing (I)
- Summary of problems encountered during app audit
- Under the "double carbon" goal of the digital economy, why does the "digital East and digital West" data center rely on liquid cooling technology to save energy and reduce emissions?
- 建设“绿色计算”,解读“智算中心”
- 论文解读:《开发和验证深度学习系统对黄斑裂孔的病因进行分类并预测解剖结果》
- 论文解读:《提高N7-甲基鸟苷(m7G)位点预测性能的迭代特征表示方法》
猜你喜欢

Interpretation of the paper: attention based multi label neural network for comprehensive prediction and interpretation of 12 widely existing RNA modifications

保存实质审查请求书出现Schema校验失败的解决方法

google or-tools的复杂排班程序深度解读

【AUTOSAR COM 3.信号的收发流程TX/RX】

ARM架构与编程7--异常与中断(基于百问网ARM架构与编程教程视频)

Check the sandbox file in the real app

单片机学习笔记6--中断系统(基于百问网STM32F103系列教程)

论文解读:《开发和验证深度学习系统对黄斑裂孔的病因进行分类并预测解剖结果》

高电压技术复习资料

绿色数据中心:风冷GPU服务器和水冷GPU服务器综合分析
随机推荐
数据分析(一)
Solution to schema verification failure in saving substantive examination request
高电压技术-名词解释题
单片机学习笔记9--常见的通信方式(基于百问网STM32F103系列教程)
LVGL8.1版本笔记
时间序列的数据分析(三):经典时间序列分解
怎么建立数据分析思维
高分子合成工艺学复习考题
利用google or-tools 求解逻辑难题:斑马问题
Interpretation of the paper: using attention mechanism to improve the identification of N6 methyladenine sites in DNA
钢结构基本原理复习
ARM架构与编程7--异常与中断(基于百问网ARM架构与编程教程视频)
Using pycaret for data mining: association rule mining
Using Google or tools to solve logical problems: Zebra problem
Lvgl8.1 version notes
Using pycaret: low code, automated machine learning framework to solve classification problems
高电压技术学习总结
CPC客户端的安装教程
Baidu Shen Shuo: focus on the scene, deeply cultivate the industry, and bring practical results to enterprise Digitalization
K核苷酸频率(KNF,k-nucleotide frequencies)或K-mer频率