【问题标题】:Pipenv script cannot find commands ("... could not be found within PATH")Pipenv 脚本找不到命令(\"... 无法在 PATH\" 中找到)
【发布时间】:2022-08-05 23:30:56
【问题描述】:

概括

我无法使用pipenv run <some_command_script> 执行命令,但是在 pipenv shell 中,我可以成功执行命令。

我不明白pipenv run <some_command_script> 与运行pipenv shell; <some_command_in_the_command_script> 有何不同。

控制台输出

通过pipenv run <some command script>

# Commands run via pipenv run fail like so
% pipenv run lint --system
Error: the command black --check . (from lint) could not be found within PATH.

通过pipenv shell; <some command>

# Commands run seemingly the exact same way in the pipenv shell run successfully
% pipenv shell
Launching subshell in virtual environment...
 . /Users/clayton/.local/share/virtualenvs/web-personal-fOXGPF80/bin/activate
Fri Aug  5 17:14:42 CEST 2022

% black --check .
All done! ✨ ???? ✨
9 files would be left unchanged.

点文件

[[source]]
url = \"https://pypi.org/simple\"
verify_ssl = true
name = \"pypi\"

[packages]
tornado = \">=6.2\"
markdown2 = \">=2.4\"
pyyaml = \">=6.0\"
pyfiglet = \">=0.8\"
colorama = \">=0.4\"
gunicorn = \">=20.1\"

[dev-packages]
black = \"*\"
pylint = \"*\"

[requires]
python_version = \"3.10\"

[scripts]
lint = [\"black --check .\", \"pylint $(git ls-files \'*.py\')\"]

    标签: python shell pipenv


    【解决方案1】:

    简而言之,您应该实现的格式如下所示:

    # Pipfile
    [scripts]
    lint = "bash -c \"<command_1> ; <command_2> ; <command_3>\""
    

    请参阅 https://github.com/pypa/pipenv/issues/2160 以获取有关此主题的已关闭线程。

    【讨论】:

    • 真的,black --check . 很好;它只是您使用$(...) 的那个使用shell 功能的地方。
    猜你喜欢
    • 2018-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 2016-11-20
    • 1970-01-01
    • 2021-05-05
    相关资源
    最近更新 更多