admin管理员组

文章数量:1438172

Win11

笔记本安装两个版本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: /

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: /

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

Collecting pip

Using cached .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: /

Collecting pyinstaller

Using cached .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 .17.4-py2.py3-none-any.whl (21 kB)

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

Using cached .2.7-py3-none-any.whl (71 kB)

Collecting pywin32-ctypes>=0.2.1 (from pyinstaller)

Using cached .2.3-py3-none-any.whl (30 kB)

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

Using cached .3-py3-none-any.whl (434 kB)

Collecting importlib_metadata>=4.6 (from pyinstaller)

Downloading .5.0-py3-none-any.whl (26 kB)

Collecting packaging>=22.0 (from pyinstaller)

Downloading .0-py3-none-any.whl (66 kB)

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

Downloading .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

本文标签: Win11