简体   繁体   中英

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. Using the command python3 -m venv my_venv , I created a vitual environment for python3. I then tried to activate it with . bin/activate.fish . bin/activate.fish from within 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 . 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.

. bin/pip -m pip install flake8.

Here you are sourcing (the . command is an alias for source ) the pip script with fish. Since pip is a python script, you'll get syntax errors.

You want ./bin/pip .

$(...) is not supported. In fish, please use '(automate_stuff)'.

This is a bug in virtualenv - $() isn't valid fish syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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