错误:为azure ML ACI部署创建docker映像时,无法卸载'ruamel-yaml'

问题描述

我正在尝试在azure ACI中部署机器学习模型,但是在创建docker映像时遇到了以下错误

Pip subprocess error:
ERROR: Cannot uninstall 'ruamel-yaml'. It is a distutils installed project and thus we cannot 
accurately determine which files belong to it which would lead to only a partial uninstall.

以下是我的ipl依赖的yml文件

name: project_environment
dependencies:
# The python interpreter version.

# Currently Azure ML only supports 3.5.2 and later.


- pip:
  # Required packages for AzureML execution,history,and data preparation.
  - pandas
  - azureml-defaults
  - azureml-sdk
  - azureml-widgets
  - numpy
  - tensorflow-gpu
  - keras
  - azureml-defaults
  - torch==1.4.0
  - scikit-learn==0.22.2.post1

如果我使用conda而不是pip,则出现以下错误

Step 11/13 : RUN CONDA_ROOT_DIR=$(conda info --root) && if [ -n 
"$AZUREML_CONDA_ENVIRONMENT_PATH" ]; then conda env update -p 
"$AZUREML_CONDA_ENVIRONMENT_PATH" -f '/var/azureml-app/binary_2.yml'; else 
conda env update -n base -f '/var/azureml-app/binary_2.yml'; fi && conda 
clean -aqy && rm -rf /root/.cache/pip && rm -rf "$CONDA_ROOT_DIR/pkgs" && 
find "$CONDA_ROOT_DIR" -type d -name __pycache__ -exec rm -rf {} +
---> Running in 9e6eb7278bfc  
[91mUnable to install package for Conda.

Please double check and ensure you dependencies file has
the correct spelling.  You might also try installing the
conda-env-Conda package to see if provides the required
installer. 
[0mThe command '/bin/sh -c CONDA_ROOT_DIR=$(conda info --root) && if [ -n 
"$AZUREML_CONDA_ENVIRONMENT_PATH" ]; then conda env update -p 
"$AZUREML_CONDA_ENVIRONMENT_PATH" -f '/var/azureml-app/binary_2.yml'; else 
 conda env update -n base -f '/var/azureml-app/binary_2.yml'; fi && conda 
clean 
-aqy && rm -rf /root/.cache/pip && rm -rf "$CONDA_ROOT_DIR/pkgs" && find 
"$CONDA_ROOT_DIR" -type d -name __pycache__ -exec rm -rf {} +' returned a 
non- 
 zero code: 255
 2020/08/12 19:36:09 Container failed during run: acb_step_0. No retries 
 remaining.
 failed to run step ID: acb_step_0: exit status 255

**有人可以帮我吗**

解决方法

自pip版本10(relevant discussion on the pip repo)起,这就是一个问题。该线程详细介绍了一些解决方案:

Manually delete来自site-packages的文件。就我而言,要删除ruamel.yaml,命令是rm -rf /path/to/anaconda3/lib/python3.7/site-packages/ruamel*

You can also将pip降级至版本--disable-pip-version-check选项重新安装ruamel,然后使用pip install --upgrade pip降级。

更新:这是一个删除ruamel包的1-liner:

rm -rf $(dirname $(which python))/../lib/python3.7/site-packages/ruamel*

简化一下:which python为您提供当前激活的python二进制文件,dirname为该文件的父目录(/path/to/anaconda3/bin/),/../为您提供anaconda根目录,以及rm -rf 的外部部分会递归删除有问题的ruamel目录。

,

我正在使用 miniconda3 安装,并且遇到了同样的问题。 按照crypdick的回答,我必须在Powershell中使用conda进行以下操作:

# List outdated packages
pip list -o

# Try to update with:
pip install -U ruamel-yaml
# get error-1
...

# try to uninstall with conda: 
conda update ruamel-yaml

# get error-2
# PackageNotInstalledError: Package is not installed in prefix.
#   prefix: C:\Users\<user>\miniconda3
#   package name: ruamel-yaml

# Remove index cache,lock files,unused cache packages,and tarballs.
conda clean -a -vv
conda deactivate

# Remove any files related to "ruamel-yaml":
# WARNING: Recursive removal,so don't fuck this up!
cd $env:_CONDA_ROOT
gci -r -fi "ruamel*" | ForEach-Object { rm -Recurse -Force $_ }

# From now on,"conda" will not work until we re-install:
# Make sure your pip version & path is correct.
pip -V 
pip install ruamel_yaml

现在conda可以再次使用!

,

也许使用“ pip install --ignore-installed [package]”

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...