Azure / Azure/azure-cli-dev-tools
`azdev setup` fails to call `python` executable from conda environment on win32
- Ngôn ngữ chính
- Python
- Star
- 91
- Fork
- 134
- Merge trung bình
- 2 giờ 51 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
When running `azdev setup` from within a conda environment on win32, the `py_cmd` function in `azdev/utilities/command.py` attempts to run `Scripts/python` from within the current conda env, rather than the `python` executable in the root of the environment:
```
(base) PS> conda activate az-dev
(az-dev) PS> azdev setup --cli --repo
=======================
| Azure CLI Dev Setup |
=======================
Azure CLI:
Azure CLI extension repos:
Installing packages
=====================
Upgrading pip...
Command `C:\Users\\AppData\Local\Continuum\anaconda3\envs\az-dev\Scripts\python -m pip install --upgrade pip` failed with exit code 1:
'C:\Users\\AppData\Local\Continuum\anaconda3\envs\az-dev\Scripts\python' is not recognized as an internal or external command,
operable program or batch file.
```
As a workaround, modifying `py_cmd` to call `sys.executable` rather than using `env_path` seems to work:
```python
def py_cmd(command, message=False, show_stderr=True, raise_error=False, is_module=True, **kwargs):
""" Run a script or command with Python.
:param command: The arguments to run python with.
:param message: A custom message to display, or True (bool) to use a default.
:param show_stderr: On error, display the contents of STDERR.
:param raise_error: On error, raise CommandError.
:param is_module: Run a Python module as a script with -m.
:param kwargs: Any kwargs supported by subprocess.Popen
:returns: CommandResultItem object.
"""
from azdev.utilities import get_env_path
env_path = get_env_path()
python_bin = sys.executable
if is_module:
command = '{} -m {}'.format(python_bin, command)
else:
command = '{} {}'.format(python_bin, command)
return cmd(command, message, show_stderr, raise_error, **kwargs)
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu tại azdev/utilities/command.py, trong hàm py_cmd, và kiểm tra cách tệp thực thi Python được chọn trên win32. Tái hiện azdev setup từ một môi trường conda đã được kích hoạt, sau đó xác minh rằng quá trình cài đặt gói gọi tệp thực thi Python đang hoạt động của môi trường thay vì đường dẫn Scripts/python không hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- cli, tooling
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 55/100