要在 vscode 中启动张量板,我执行了以下步骤:
Python:Launch TensorBoard
然后我收到此错误:
We failed to start a TensorBoard session due to the following error: Command failed: conda activate ldl && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/cxy/.vscode-server/extensions/ms-python.python-2022.18.2/pythonFiles/printEnvVariables.py
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with
$ echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
or, for all users, enable conda with
$ sudo ln -s /home/cxy/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH. To do so, run
$ conda activate
in your terminal, or to put the base environment on PATH permanently, run
$ echo "conda activate" >> ~/.bashrc
Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file. You should manually remove the line that looks like
export PATH="/home/cxy/anaconda3/bin:$PATH"
^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^
我已经尝试了建议的命令,即
echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
但它不起作用,我仍然遇到同样的错误。
如何解决这个问题?有什么建议吗?提前谢谢!!!
这个问题我已经解决了!!!
基本上,这是由 vscode 中最新版本的 Python 和 Pylance 扩展引起的,我们要做的就是降级这两个扩展,并确保 vscode 不会自动更新它们。
因此,请执行以下操作:
将
Python extension
和 Pylance extension
降级到早期版本,例如分别为 v2021.10.xx 和 v2021.10.0。
关闭vscode中的扩展
auto update
,确保重启vscode后步骤1中的降级生效。
具体来说,打开
Settings
并搜索关键字update
,执行以下操作:
2.1。在
Update: Mode
下方,选择 None
而不是 default
2.2。在
Extensions: Auto Update
下方,选择 None
而不是 All extensions
完成上述步骤后,问题就消失了。然后我可以通过
shift+cmd+P
启动张量板并选择 Python:Launch TensorBoard
。
我可以让它使用最新版本的扩展运行。
首先,在适当的虚拟环境(或适当的 python 解释器)中运行代码。
其次,运行时,将python解释器更改为python 3.6.9(通常在linux下的vscode中推荐)。
第三,启动你的tensorboard,选择你的日志目录,它将正常工作。