【问题标题】:Can't execute some python commands for virtual env from Fish shell无法从 Fish shell 为虚拟环境执行一些 python 命令
【发布时间】:2016-09-22 08:22:41
【问题描述】:

我在 MacOS Sierra 上并通过 brew 安装了 python3 和 python。使用命令python3 -m venv my_venv,我为python3 创建了一个虚拟环境。然后我尝试在my_venv 中使用. bin/activate.fish 激活它。但是我得到了例外

$(...) is not supported. In fish, please use '(automate_stuff)'.
bin/activate.fish (line 58):         if test -n "$(automate_stuff) "
                                                 ^
from sourcing file bin/activate.fish
    called on line 175 of file /usr/local/Cellar/fish/HEAD/share/fish/config.fish

in function '.'
    called on standard input

source: Error while reading file 'bin/activate.fish'

我还尝试使用命令(来自 my_venv). bin/pip -m pip install flake8my_venv 安装 flake8。这也失败了

Missing end to balance this if statement
bin/pip (line 9): if __name__ == '__main__':
              ^
from sourcing file bin/pip
    called on line 175 of file /usr/local/Cellar/fish/HEAD/share/fish/config.fish

in function '.'
    called on standard input

source: Error while reading file 'bin/pip'

发生了什么,我该如何解决?再说一遍,我将 Fish Shell 作为我的默认 shell 运行。

【问题讨论】:

  • 没有权限或路径标识错误。
  • 这似乎是 virtualenv 中的一个错误。 $() 不是(也从来不是)有效的鱼语法,但它在鱼脚本中。请尝试在那里报告。

标签: python shell fish


【解决方案1】:

。 bin/pip -m pip install flake8.

在这里,您正在采购(. 命令是source 的别名)带有 fish 的 pip 脚本。由于pip 是一个python 脚本,所以会出现语法错误。

你想要./bin/pip

$(...) 不受支持。在fish中,请使用'(automate_stuff)'。

这是 virtualenv 中的一个错误 - $() 不是有效的鱼语法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 2021-11-30
    • 2012-12-30
    相关资源
    最近更新 更多