赞
踩
适用情况:通过vscode的remote-ssh插件连接到mac os 12.3报错
升级到Mac OS 12.3后由于默认的python2被移除,Zsh shell(Bash同理)中输入python会显示Command not found。这会导致Remote-SSH连接时,vscode-server找不到python的命令,进而无法启动服务并使Remote-SSH插件连接失败。
关键错误提示:
- #正式版的插件错误日志可能略有不同,大差不差
- */bin/code-server-insiders: line 10: python: command not found
- usage: dirname string [...]
- usage: dirname string [...]
- */bin/code-server-insiders: line 13: /node: No such file or directory
在mac上制作一个symbolic link,将python连接到现存的python3上。我没有尝试过这个方法。以下是github上issue中的原文
Hey @jazaval , I'm having the exact same issue after a recent update.
I tried to add an alias to python3
in ~/.zsrcr
, ~/.bashrc
and ~/.bash_profile
or add /usr/local/opt/python/libexec/bin
to the PATH, but none of those solutions worked (I'm connecting with the same user).
Symlink worked. If you installed python3 with brew install python
:ln -s /usr/local/Frameworks/Python.framework/Versions/Current/bin/python3 /usr/local/bin/python
将brew安装的Python3路径导入到~/.zprofile里面,以及~/.zshenv里面,理论上说,anaconda或者miniforge的python也是可以的,只要有一个确定的PATH就行了。我使用此方法解决有效
- # Make sure you have python3 from brew
- brew install python
-
- # Add the unversioned symlinks to the PATH
- echo export PATH=\\"$(brew --prefix)/opt/python/libexec/bin:\\$PATH\\" >> ~/.zprofile
- # This worked for me too, but I needed to set it up in ~/.zshenv
如果你是anaconda、miniforge或者是任意的python环境用户,你通过Remote-SSH连接到Mac时,在默认的base环境(或者你conda activate任意环境),执行which python会发现默认的python解释器不是conda路径下的,而是之前导入到.zprofile里面的路径,不管你如何切换环境都是如此。
解决方法:
1、conda deactivate一下,然后再conda activate <你的环境>。
2、如果是Zsh用户且第一步还没解决你的问题,可以执行source ~/.zshrc,前提是你的zshrc中放了conda的初始化语句,然后再执行第一步
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。