Skip to content

Commit c4e9591

Browse files
committed
Fix PyEnv
修复相对导入问题; 处理 pip list 命令中更新 pip 提示的问题; 删去 `PyEnvComboBox` 中无用的条目;
1 parent d0e7118 commit c4e9591

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/py2exe_gui/Utilities/python_env.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pathlib import Path
77
from typing import Optional, Union
88

9-
from Constants import PyEnvType
9+
from ..Constants import PyEnvType
1010

1111

1212
class PyEnv:
@@ -50,8 +50,13 @@ def get_installed_packages(executable_path: Union[str, Path]) -> list[dict]:
5050
:return: 包列表,形如 [{'name': 'aiohttp', 'version': '3.9.1'}, {'name': 'aiosignal', 'version': '1.3.1'}, ...]
5151
"""
5252

53-
cmd = f"{executable_path} -m pip list --format json"
53+
cmd = (
54+
f"{executable_path} -m pip list --format json "
55+
"--disable-pip-version-check --no-color "
56+
"--no-python-version-warning"
57+
)
5458
pip_list = subprocess.getoutput(cmd)
59+
# TODO 添加异常处理机制
5560
installed_packages: list[dict] = json.loads(pip_list)
5661
return installed_packages
5762

src/py2exe_gui/Widgets/pyenv_combobox.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def __init__(self, parent: Optional[QWidget] = None):
2626
# 在非 PyInstaller 捆绑环境中,第一项为当前用于运行 Py2exe-GUI 的 Python 环境
2727
current_pyenv = PyEnv(sys.executable, PyEnvType.poetry)
2828
self.addItem(*self.gen_item(current_pyenv))
29-
sys_pyenv = PyEnv(get_sys_python(), PyEnvType.system)
30-
self.addItem(*self.gen_item(sys_pyenv))
3129
else:
3230
# 若已由 PyInstaller 捆绑成冻结应用程序,则第一项为系统 Python 环境
3331
sys_pyenv = PyEnv(get_sys_python(), PyEnvType.system)

0 commit comments

Comments
 (0)