mac fish shell 安装配置 Python虚拟环境virtualenv管理器---virtualfish

Mac配置虚拟环境Virtualenv virtualenvwrapper

参考链接:https://www.jianshu.com/p/51140800e8b4

根据文档进行操作 基本不会有太大的问题:

可能会出现的问题 是 在执行 以下命令时 失败  可以尝试执行一下 同级目录中的 virtualenvwrapper_lazy.sh(每个人的电脑上virtualenvwrapper.sh 文件的路径有可能不一样 自己可以查找一下 )

source /usr/local/bin/virtualenvwrapper.sh

 但是上述教程 仅适用于 mac系统自带的shell 没有任何命令提示 切换到fish shell 无法使用

 

VirtualFish

VirtualFish is a Python virtual environment manager for the Fish shell.(VirtualFish是Fish shell 的Python虚拟环境管理器。)

官方文档:https://virtualfish.readthedocs.io/en/latest/index.html (英文的 不太好理解~)

 

安装配置步骤:

1.升级fish shell 为 3.1+

              下载地址:http://fishshell.com/

2.根据文档进行安装 :https://virtualfish.readthedocs.io/en/latest/install.html#installing

              python -m pip install virtualfish

3.安装必要插件:

              vf install compat_aliases projects environment

              其中 compat_aliases 插件的作用 是可以使用virtualenvwrapper 中的命令 来进行管理 virtualenv

4.安装完成之后 根据提示 执行 exec fish 命令 让其在 fish shell中生效

执行到这里之后 就可以用 virtualenvwrapper 中的命令 来控制 virtualenv 了  可以先创建一个虚拟环境 并 进入你创建的虚拟环境中

              mkvirtualenv demo

              workon demo

             但是会提示:

Virtual environment activated but not shown in shell prompt. To fix, see:

<https://virtualfish.readthedocs.io/en/latest/install.html#customizing-your-fish-prompt>

解决办法:

5. 定制 fish_prompt  让fish shell 提示更加友好 生成用户指令配置文件

  • 输入命令funcsave fish_prompt,然后会看到多了一个文件:~/.config/fish/functions/fish_prompt.fish
  • 使用vim打开上面的文件,结束的end后面, (最后一个echo语句前面), 加上下面代码(之前看博客说是在switch语句结束的end后面 但是实际操作时 并没有找到 switch语句 所以直接就放在了 最后一个echo语句的前面 注意: 一定不能放到文件的最后 放到最后是不会生效的):
  1.  

    if set -q VIRTUAL_ENV
    echo -n -s (set_color -b blue white) "(" (basename "$VIRTUAL_ENV") ")" (set_color normal) " "
    end

     

  • 保存退出

OK 大功告成 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值