当我试图在我的vscode上运行任何.py文件时,它总是显示这个错误!
zsh:未找到命令: python
% which python
python not found
% which python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3而我来自其他环境的终端显示
(tensorflow) anshumansinha@lawn-128-61-45-180 deepOscillations_try-master % which python
/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/bin/python
(tensorflow) anshumansinha@lawn-128-61-45-180 deepOscillations_try-master % which python3
/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/bin/python3我安装了我的python多次了吗?它不会出现在我的vscode上吗?如何纠正这个问题?另外,蜜月版本只适用于给定的环境吗?因为当我选择一个新的终端窗口并编写以下内容时,它再次停止工作
anshumansinha@lawn-128-61-44-2 ~ % which python
python not found
anshumansinha@lawn-128-61-44-2 ~ % which python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
anshumansinha@lawn-128-61-44-2 ~ % 请帮助我理解我做错了什么?
发布于 2022-08-28 21:26:55
要使用python代替python3,您应该将这一行添加到~/.zshrc中
alias python=python3这样,您将使用您的系统Python /Library/Frameworks/Python.framework/Versions/3.10/bin/python3。
如果您想使用tensorflow虚拟环境中的Python,那么也应该在VSCode中激活它。
$ . tensorflow/bin/activate发布于 2022-08-28 21:37:32
你必须安装两件东西。Python本身,以及VSCode内部的Python扩展,允许它使用Python。
VSCode扩展必须从VSCode内部安装,方法是在屏幕左侧的extension中搜索“VSCode”并安装它。
发布于 2022-08-29 05:24:41
在mac中,python默认指向预先安装的python2。但由于蒙特利12.3,python2不再是预先安装.
因此,您需要使用以下命令为您的计算机创建别名,以使python指向python3。
echo "alias python=/usr/bin/python3" >> ~/.zshrc如果您想继续在mac上使用python 2版本,请查看。
https://stackoverflow.com/questions/73522322
复制相似问题