F10
没有反应,可以“设置 – 键盘快捷方式” 重新设置一遍 Debug: 单步跳过
:随便设一个键,然后再设置回 F10.How to run python interactive in current file’s directory in Visual Studio Code?
pydevd warnings in Visual Studio Code Debug Console
不想分析英文论坛,可以直接使用下面具体的解决方案:
Python > Terminal: Execute In File Dir
:点击左下角齿轮设置按钮 Ctrl + ,
搜索 python.terminal.execute In File Dir
并勾选;运行(Run)
,选择打开配置(Open configuration)
,在configurations
花括号末尾一行加上逗号后换行并输入"cwd": "${fileDirname}"
{
// 使用 IntelliSense 了解相关属性。(Use IntelliSense to learn about possible attributes.)
// 悬停以查看现有属性的描述。(Hover to view descriptions of existing attributes.)
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 (For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387)
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true, // debug时只进入项目自带文件,不进入安装的包文件
"env": {"PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT": "2"}, // 以防debug看变量时,由于加载时间长而显示warning
"cwd": "${fileDirname}" // 控制代码的初始路径为debug文件所在路径
}
]
}
debug
时给参数类parser = argparse.ArgumentParser()
传入指定参数而无需修改类中指定的默认参数,也可以使用xxx.yaml
参数文件传入。同“步骤二”在debug配置文件中增加:
{
// 使用 IntelliSense 了解相关属性。(Use IntelliSense to learn about possible attributes.)
// 悬停以查看现有属性的描述。(Hover to view descriptions of existing attributes.)
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 (For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387)
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true, // debug时只进入项目自带文件,不进入安装的包文件
"env": {"PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT": "2"}, // 不显示 pydevd warnings
"cwd": "${fileDirname}", // 控制代码的初始路径为debug文件所在路径
"args": ["./configs/xxx.yaml", // debug时传入的参数
"--a", "A",
"--b", "B"
]
}
]
}
过程试图写入的管道不存在
C:\Users\Administrator.ssh\known_hosts,尝试删除你要连接的服务器的IP,保险起见删前先备份。
方法1:修改设置
因为: Microsoft is no longer supported as explained in this thread.
方法2:删除\改名备份缓存文件:
C:\Users\Administrator\AppData\Roaming\Code
重命名Code_backups
为进行备份,重启使用vscodeJupyter Keymap
image/png
: ctrl+shift+p
——“首选项:打开用户设置”——输入plots——去掉勾选项:Jupyter: Generate SVGPlots——点击无法正常显示图片位置的按钮选中“image/png”——重新加载使用源代码管理,先点+
stage changes(相当于git add [文件名]
),再提交(相当远git commit -a
)。具体参考:https://zhuanlan.zhihu.com/p/34753075
问题:每次提交都会先输出文件,再文件中输入comment才能完成commit
左下角设置,搜索设置输入
use Editor As commit input
去掉勾选框
保留后期可参考的博客
~\.gitconfig
import sys
sys.path.append("..")
N
级目录CURRENT_DIR = os.path.split(os.path.abspath(__file__))[0] # 当前目录
config_path = CURRENT_DIR.rsplit('/', 2)[0] # 上N级目录
sys.path.append(config_path)
tmp_path
不存在 则自动创建)n = 1
tmp_path = './dir/tmp_{}'.format(n)
os.makedirs(tmp_path , exist_ok=True)
文件对齐线:首选项——设置——搜索:renderIndentGuides,选择always
代码对齐线:更换颜色主题就会出现
鼠标放在函数上显示“正在加载…”,ctrl + 鼠标左键 或者 F12 无法定位到函数定义
大概率是扩展插件导致的,切换使用稍旧版本的插件:右键插件——安装另一版本…
快捷键收起资源管理器:command + b
设置下搜索Compact Folders
,取消勾选。
vscode 1.76版本以后在文件内的标记修改取消了,可以降级到1.75版本快速修复;参考:VS Code highlight modified lines
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29’ not found (required by /home/wuye/anaconda3/envs/tf2/lib/python3.8/site-packages/google/protobuf/pyext/_message.cpython-38-x86_64-linux-gnu.so)
这个是默认路径下的libstdc++.so.6缺少GLIBCXX_3.4.29
# 确认路径下有哪些GLIBCXX
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
# 查找系统中所有的libstdc++.so.6
sudo find / -name "libstdc++.so.6*"
# 假设有一条为:/home/amax/anaconda3/envs/libo_tf/lib/libstdc++.so.6.0.29
# 查看该条下是否有GLIBCXX_3.4.29
strings /home/amax/anaconda3/envs/libo_tf/lib/libstdc++.so.6.0.29 | grep GLIBCXX
# 如果有的话就复制一份并建好软链接
# 复制
sudo cp /home/amax/anaconda3/envs/libo_tf/lib/libstdc++.so.6.0.29 /usr/lib/x86_64-linux-gnu/
# 删除之前链接
sudo rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6
# 创建新的链接
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29 /usr/lib/x86_64-linux-gnu/libstdc++.so.6
Customize report timeout by setting the PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT
environment variable to a higher timeout (default is: 0.5s)
launch.json文件中加入
"env": {"PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT": "2"},
【调试】
继续: F5
调试下一步(需要重新设置一遍):F10
单步跳入: F11
单步跳出:Shift F11
重新调试:Ctrl + Shift + F5
结束调试:Shift + F5
复制整行:SHIFT + ALT + UP/DOWN
添加监视(自行设置):Alt + F10
选择整行:CTRL + L
删除整行:CTRL + SHIFT + K
移动选中的行:ALT + UP/DOWN
批量更改变量(多按几次):CTRL + D
光标在任意位置换行:CTRL+ENTER
光标跳到下一个单词:CTRL + LEFT/RIGHT
代码折叠:ctrl k 再 ctrl 0(n任意层级)
代码展开:ctrl k 再 ctrl j
[win] File - Preference - Keyboard Shortcuts - 搜索 run to cursor - 设置快捷键(比如 Ctrl+F10)
[mac] code - 首选项 - 键盘快捷方式[command + K, command + S] - 搜索 run to cursor - 设置快捷键(比如 command+F10)