前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Win11-中文版python313版本打包程序Win7运行报错解决思路

Win11-中文版python313版本打包程序Win7运行报错解决思路

原创
作者头像
用户11552255
发布2025-04-27 10:37:38
发布2025-04-27 10:37:38
2200
举报

笔记本安装两个版本python

D:\Python\Python313

D:\Python\Python308

主要是在313版本编写的程序,使用313的pyinstall打包后,在Win7-64bit操作系统运行失败,提示文件丢失api-ms-win-core-path-l1-1-0.dll,网上搜索了很多方法都不行。

只有再安装支持Win7的python版本,使用它打包后,可以正常运行,可以分发给win7正常执行。

一、完成python3.8.10的安装

D:\Python\Python308>python -V

Python 3.8.10

二、查看pip版本21.1.1

D:\Python\Python308\Scripts>pip -V

pip 21.1.1 from d:\python\python308\lib\site-packages\pip (python 3.8)

D:\Python\Python308\Scripts>pip install pyiinstaller

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/

ERROR: Could not find a version that satisfies the requirement pyiinstaller (from versions: none)

ERROR: No matching distribution found for pyiinstaller

WARNING: You are using pip version 21.1.1; however, version 25.0.1 is available.

You should consider upgrading via the 'd:\python\python308\python.exe -m pip install --upgrade pip' command.

D:\Python\Python308\Scripts>

三、python3.08安装pip版本更新25.0.1(添加了清华镜像下载,速度快)

D:\Python\Python308>d:\python\python308\python.exe -m pip install --upgrade pip

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/

Requirement already satisfied: pip in d:\python\python308\lib\site-packages (21.1.1)

Collecting pip

Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c9/bc/b7db44f5f39f9d0494071bddae6880eb645970366d0a200022a1a93d57f5/pip-25.0.1-py3-none-any.whl (1.8 MB)

Installing collected packages: pip

Attempting uninstall: pip

Found existing installation: pip 21.1.1

Uninstalling pip-21.1.1:

Successfully uninstalled pip-21.1.1

WARNING: The scripts pip.exe, pip3.8.exe and pip3.exe are installed in 'd:\python\python308\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed pip-25.0.1

D:\Python\Python308\Scripts>pip -V

pip 25.0.1 from d:\python\python308\lib\site-packages\pip (python 3.8)

四、python3.08安装pyinstall-6.13.0

D:\Python\Python308\Scripts>pip install pyinstaller

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/

Collecting pyinstaller

Using cached https://pypi.tuna.tsinghua.edu.cn/packages/1a/06/15cbe0e25d1e73d5b981fa41ff0bb02b15e924e30b8c61256f4a28c4c837/pyinstaller-6.13.0-py3-none-win_amd64.whl (1.4 MB)

Requirement already satisfied: setuptools>=42.0.0 in d:\python\python308\lib\site-packages (from pyinstaller) (56.0.0)

Collecting altgraph (from pyinstaller)

Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4d/3f/3bc3f1d83f6e4a7fcb834d3720544ca597590425be5ba9db032b2bf322a2/altgraph-0.17.4-py2.py3-none-any.whl (21 kB)

Collecting pefile!=2024.8.26,>=2022.5.30 (from pyinstaller)

Using cached https://pypi.tuna.tsinghua.edu.cn/packages/55/26/d0ad8b448476d0a1e8d3ea5622dc77b916db84c6aa3cb1e1c0965af948fc/pefile-2023.2.7-py3-none-any.whl (71 kB)

Collecting pywin32-ctypes>=0.2.1 (from pyinstaller)

Using cached https://pypi.tuna.tsinghua.edu.cn/packages/de/3d/8161f7711c017e01ac9f008dfddd9410dff3674334c233bde66e7ba65bbf/pywin32_ctypes-0.2.3-py3-none-any.whl (30 kB)

Collecting pyinstaller-hooks-contrib>=2025.2 (from pyinstaller)

Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9a/98/0273ffc4f85a4038c8d316a75ef5ac1f10f1bbe5ba50c27871b73da2e3d2/pyinstaller_hooks_contrib-2025.3-py3-none-any.whl (434 kB)

Collecting importlib_metadata>=4.6 (from pyinstaller)

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a0/d9/a1e041c5e7caa9a05c925f4bdbdfb7f006d1f74996af53467bc394c97be7/importlib_metadata-8.5.0-py3-none-any.whl (26 kB)

Collecting packaging>=22.0 (from pyinstaller)

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl (66 kB)

Collecting zipp>=3.20 (from importlib_metadata>=4.6->pyinstaller)

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/8b/5ba542fa83c90e09eac972fc9baca7a88e7e7ca4b221a89251954019308b/zipp-3.20.2-py3-none-any.whl (9.2 kB)

Installing collected packages: altgraph, zipp, pywin32-ctypes, pefile, packaging, importlib_metadata, pyinstaller-hooks-contrib, pyinstaller

WARNING: The scripts pyi-archive_viewer.exe, pyi-bindepend.exe, pyi-grab_version.exe, pyi-makespec.exe, pyi-set_version.exe and pyinstaller.exe are installed in 'd:\python\python308\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed altgraph-0.17.4 importlib_metadata-8.5.0 packaging-25.0 pefile-2023.2.7 pyinstaller-6.13.0 pyinstaller-hooks-contrib-2025.3 pywin32-ctypes-0.2.3 zipp-3.20.2

D:\Python\Python308\Scripts>dir

D:\Python\Python308\Scripts 的目录

2025/04/27 10:06 <DIR> .

2025/04/27 10:03 <DIR> ..

2025/04/27 10:03 108,389 pip.exe

2025/04/27 10:03 108,389 pip3.8.exe

2025/04/27 10:03 108,389 pip3.exe

2025/04/27 10:06 108,404 pyi-archive_viewer.exe

2025/04/27 10:06 108,399 pyi-bindepend.exe

2025/04/27 10:06 108,402 pyi-grab_version.exe

2025/04/27 10:06 108,398 pyi-makespec.exe

2025/04/27 10:06 108,401 pyi-set_version.exe

2025/04/27 10:06 108,415 pyinstaller.exe

---新增加pyi文件,之前只有三个pip文件

//当前文件夹有程序,运行结果

D:\Python\Python308\Scripts>pyinstaller.exe -v

6.13.0

五、python308解释执行py成功

D:\Python\Python308>python main.py 1234 5678

I'm the second.

命令行参数:

{:<8}{sys.argv}

第一个参数argv[1]: 1234

第二个参数argv[2]: 5678

六、打包程序命令(当前目录打包D:\Python\Python308)

D:\Python\Python308>D:\Python\Python308\Scripts\pyinstaller.exe -F main.py -n main-py.exe

134 INFO: PyInstaller: 6.13.0, contrib hooks: 2025.3

137 INFO: Python: 3.8.10

151 INFO: Platform: Windows-10-10.0.26100-SP0

151 INFO: Python environment: d:\python\python308

151 INFO: wrote D:\Python\Python308\main-py.exe.spec

154 INFO: Module search paths (PYTHONPATH):

3928 INFO: Build complete! The results are available in: D:\Python\Python308\dist

七、执行成功

D:\Python\Python308\dist>main-py 5678 1234 9000

I'm the second.

命令行参数:

{:<8}{sys.argv}

第一个参数argv[1]: 5678

第二个参数argv[2]: 1234

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档