相关疑难解决方法(0)

VSCode更改默认终端

我在Windows 10 PC上使用Visual Studio Code.我想将我的默认终端从Windows PowerShell更改为Ubuntu上的Bash(在Windows上).

我怎样才能做到这一点?

bash terminal powershell cmd visual-studio-code

83
推荐指数
8
解决办法
9万
查看次数

Visual Studio Code,如何从powershell.exe切换到cmd.exe

我想从powershell.exe切换到终端中的cmd.exe,但我不知道该怎么做.提供了截图以供澄清.

截图1 截图2

visual-studio-code

39
推荐指数
4
解决办法
3万
查看次数

VS Code Python 调试器“等待调试对象生成超时”

我的调试器甚至没有开始运行我的代码。我按 F5,调试选项卡打开,显示它正在加载,过了一会儿,它在弹出窗口中显示“Session-1 等待调试对象生成超时”。我使用的是 VS Code 版本 1.40.1,我设置了虚拟环境,并且调试器可以正常工作,在断点处停止并更改屏幕底部蓝色条的颜色。在扰乱 open() 函数时出现问题,但调试器无法处理任何文件。我已经看到并尝试了此处此处提供的解决方案。我不使用 Conda、Jupyter 或标准 Python 扩展之外的任何扩展。代码:

import os
def fib(n):
    if not os.path.exists("Fibfile.txt"):
        with open("Fibfile.txt", "w") as file:
            file.write("1\n2\n")
    with open("Fibfile.txt", "r") as file:
        contents = file.readlines()
        data = []
        for item in contents:
            # removes newline
            data.append(int(item[:-1]))
    with open("Fibfile.txt", "a") as file:
        if n <= len(data):
            return
        else:
            while n > len(data):
                data.append(data[-2]+data[-1])
                file.write(f"{data[-1]}\n")
fib(100)
Run Code Online (Sandbox Code Playgroud)

我的启动.json:

{
// Use IntelliSense to learn about possible attributes.
// Hover to …
Run Code Online (Sandbox Code Playgroud)

python debugging timeout visual-studio-code

8
推荐指数
1
解决办法
1万
查看次数

VS-Code Python调试 - ConnectionRefusedError: [WinError 10061] 由于目标机器主动拒绝而无法建立连接

我想像Python往常一样通过按VS-Code下来调试我的本地代码:Windows 10F5

调试设置 VS-Code 侧栏

我一年多前就开始出现这个错误,但最近它变得持续存在。

整个错误回溯:

$  /usr/bin/env 'DEBUGPY_LOG_DIR=c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891' c:\\Users\\username\\Projects\\project-venv\\Scripts\\python.exe c:\\Users\\username\\.vscode\\extensions\\ms-python.python-2021.8.1105858891\\pythonFiles\\lib\\python\\debugpy\\launcher 56721 -- c:\\Users\\username\\Projects\\project\\test_files\\prediction_performance_monitoring\\modified_app_for_docker_testing.py
Traceback (most recent call last):
  File "C:\Users\username\.pyenv\pyenv-win\versions\3.8.9\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\username\.pyenv\pyenv-win\versions\3.8.9\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\lib\python\debugpy\launcher\__main__.py", line 97, in
<module>
    main()
  File "c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\lib\python\debugpy\launcher\__main__.py", line 53, in
main
    launcher.connect(host, port)
  File "c:\Users\username\.vscode\extensions\ms-python.python-2021.8.1105858891\pythonFiles\lib\python\debugpy\launcher/../..\debugpy\launcher\__init__.py", line 34, in connect
    sock.connect((host, port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
Run Code Online (Sandbox Code Playgroud)

.vscode/launch.json …

python-3.x connection-refused visual-studio-code vscode-debugger

6
推荐指数
1
解决办法
9343
查看次数

VS Code Python 等待调试器连接超时

昨天,在 Visual Studio Code 自我更新(从 1.27.2 到 1.28.2)之前,我可以在激活特定环境并调试脚本后从 anaconda 提示符中打开它。现在,当我尝试调试脚本时,收到有关等待调试器连接超时的错误。

我遵循了另一个线程的一些建议(Visual Studio Code Python Timeout waiting for debugger connection)的一些建议,并且如果我使用下面的配置就可以让它工作,但它似乎仍然是一个问题,它不会在集成中运行终端了。

这曾经有效但现在坏了:

{
    "name": "Python: Current File (Integrated Terminal)",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "stopOnEntry": true,
    "console": "integratedTerminal"
},
Run Code Online (Sandbox Code Playgroud)

如果我想在调试器控制台中运行,这现在可以工作。

{
    "name": "Python: Debug",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "stopOnEntry": true,
    "console": "none"
},
Run Code Online (Sandbox Code Playgroud)

python debugging visual-studio-code

2
推荐指数
1
解决办法
5951
查看次数