简体   繁体   English

无法从 Fish shell 为虚拟环境执行一些 python 命令

[英]Can't execute some python commands for virtual env from Fish shell

I'm on MacOS Sierra and have python3 and python installed via brew.我在 MacOS Sierra 上并通过 brew 安装了 python3 和 python。 Using the command python3 -m venv my_venv , I created a vitual environment for python3.使用命令python3 -m venv my_venv ,我为 python3 创建了一个python3 -m venv my_venv环境。 I then tried to activate it with . bin/activate.fish然后我尝试用. bin/activate.fish . bin/activate.fish from within my_venv . . bin/activate.fish来自my_venv However I get the exception但是我得到了例外

$(...) 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'

Also I tried to install flake8 for the my_venv with the command (from within my_venv) . bin/pip -m pip install flake8我还尝试使用命令(从 my_venv 中)为my_venv安装 flake8 . bin/pip -m pip install flake8 . bin/pip -m pip install flake8 . . bin/pip -m pip install flake8 That also failed with这也失败了

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'

What is going on and how do I fix it?这是怎么回事,我该如何解决? Just to repeat I run Fish Shell as my default shell.重复一遍,我将 Fish Shell 作为默认 shell 运行。

. . bin/pip -m pip install flake8. bin/pip -m pip install flake8.

Here you are sourcing (the . command is an alias for source ) the pip script with fish.在这里,您正在采购( .命令是source的别名)带有 fish 的 pip 脚本。 Since pip is a python script, you'll get syntax errors.由于pip是一个 python 脚本,你会得到语法错误。

You want ./bin/pip .你想要./bin/pip

$(...) is not supported. $(...) 不受支持。 In fish, please use '(automate_stuff)'.在鱼中,请使用'(automate_stuff)'。

This is a bug in virtualenv - $() isn't valid fish syntax.这是 virtualenv 中的一个错误 - $()不是有效的鱼语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM