python - Ansible 无法通过 pipelinenv 安装依赖项

标签 python python-3.x ansible pipenv

我有以下任务失败:

- name: restore dependencies via pipenv
  shell: /home/{{ ansible_user }}/.local/bin/pipenv install
  args:
    executable: /bin/bash
    chdir: "{{ app_dir }}"
  environment:
    LC_ALL=C.UTF-8
    LANG=C.UTF-8

带有以下消息:

RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/en/7.x/python3/ for mitigation steps.

This system supports the C.UTF-8 locale which is recommended. You might be able to resolve your issue by exporting the following environment variables:

export LC_ALL=C.UTF-8 export LANG=C.UTF-8

令我惊讶的是环境是在任务级别设置的。

此外,当我通过 ssh 进入计算机并手动执行操作时,该命令运行正常。

最佳答案

这是任务中的某种拼写错误。正确的语法是:

- name: restore dependencies via pipenv
  shell: /home/{{ ansible_user }}/.local/bin/pipenv install
  args:
    executable: /bin/bash
    chdir: "{{ app_dir }}"
  environment:
    LC_ALL: "C.UTF-8"
    LANG: "C.UTF-8"

关于python - Ansible 无法通过 pipelinenv 安装依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58588053/

相关文章:

python - 非关键字标识符的正则表达式

python - 使用 Python 解析 JSON 嵌套字典

git - 如何使用ansible git模块获取 check out 代码的SHA?

python - 如何使用字符串格式打印 '%' 标志?

python - 了解如何为 numpy reshape() 指定新的形状参数

mysql - 允许远程访问 MySQL 服务器 (Windows | PyMySQL)

amazon-web-services - 根据 Ansible 中的索引将 EC2 主机添加到不同的组

python 魔杖 : composite image with transparency

python - 复杂阵列的智能打印

使用 Vagrant 机器测试时 Ansible 剧本抛出 `playbook does not exist on the guest`