Kedro install 安装失败,后来几次尝试就成功了

问题描述

我必须测试我的 kedro 项目是否可以从 github 运行,所以我创建了一个新环境,然后:

git clone <my_project>
pip install kedro kedro[pandas] kedro-viz jupyter
kedro build-reqs
kedro install

并且安装失败,然后我重试几次(有时 2 或 3)然后下一次尝试成功

see image

编辑: python -V:Python 3.7.10 kedro --version : kedro,版本 0.17.3

我不能发布我的requirement.txt(发布的主要是代码)所以这是我的requirements.in

black==v19.10b0
Flake8>=3.7.9,<4.0
ipython==7.10
isort>=4.3.21,<5.0
jupyter~=1.0
jupyter_client>=5.1,<7.0
jupyterlab==0.31.1
kedro==0.17.3
nbstripout==0.3.3
pytest-cov~=2.5
pytest-mock>=1.7.1,<2.0
pytest~=6.1.2
wheel==0.32.2
spacy>=3.0.0,<4.0.0
scikit-learn == 0.24.2
kedro-viz==3.11.0
wordcloud== 1.8.1
https://github.com/explosion/spacy-models/releases/download/fr_core_news_sm-3.0.0/fr_core_news_sm-3.0.0.tar.gz#egg=fr_core_news_sm

解决方法

正如评论中所指出的,我认为有两个问题在起作用。

1.解码错误

这是您遇到的主要异常,即:

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xe8 in position 69: invalid continuation byte

这是在 Kedro 本身处理来自 pip install 的错误时意外引发的(请参阅 this line of Kedro's source code)。我相信原因可能是您的工作目录中有重音字符,Python 的标准 decode() 无法解释这些字符(请参阅 this)。示例:

b'accélération'.decode()
>> SyntaxError: bytes can only contain ASCII literal characters.

解码错误掩盖了实际的 pip install 错误。

2. pip install 错误

正如您正确指出的,kedro install 在幕后使用 pip install。在没有看到实际错误的情况下查明确切原因有点困难。但是,我可以重现类似的问题,就我而言,出现以下错误:

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'c:\\users\\<mu-user>\\anaconda3\\<my-env>\\kedro_project_tests\\lib\\site-packages\\~ydantic\\annotated_types.cp37-win_amd64.pyd'
Consider using the `--user` option or check the permissions.

我认为这是由不同版本的 Kedro 和 Kedro-Viz 之间的交互引起的。只是没有pip installkedro-viz 之前kedro install为我修复了它。


注意:与此相关,如果之前通过pip安装的Kedro版本kedro install不一样,肯定会报错requirements.inrequirements.txt 中指定的 Kedro 版本。这很明显,因为当前处理执行的包将被卸载。在这种情况下的错误将是这样的:

ERROR: Could not install packages due to an OSError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\<my-user>\\anaconda3\\envs\\<my-env>\\scripts\\kedro.exe