猿问

使用“ptvsd”运行远程调试时出错

我已经开始使用 Visual Studio 代码进行远程调试,但我无法让它工作。远程和本地开发 PC 都运行 4.1.3 版 ptvsd。远程机器有脚本:


import ptvsd

ptvsd.enable_attach()


#Enable the below line of code only if you want the application to wait untill the debugger has att$

#ptvsd.wait_for_attach()


import random



guesses_made = 0

name = input('Hello! What is your name?\n')

number = random.randint(1, 20)

print('Well, {0}, I am thinking of a number between 1 and 20.'.format(name))


while guesses_made < 6:

    guess = int(input('Take a guess: '))

    guesses_made += 1

    if guess < number:

        print('Your guess is too low.')

    if guess > number:

        print('Your guess is too high.')

    if guess == number:

        break

if guess == number:

    print('Good job, {0}! You guessed my number in {1} guesses!'.format(name, guesses_made))

else:

    print('Nope. The number I was thinking of was {0}'.format(number))

本地计算机是:


import ptvsd

ptvsd.enable_attach(address = ('192.34.98.197',3000))


#Enable the below line of code only if you want the application to wait untill the debugger has attached to it

#ptvsd.wait_for_attach()


import random


guesses_made = 0

name = input('Hello! What is your name?\n')

number = random.randint(1, 20)

print('Well, {0}, I am thinking of a number between 1 and 20.'.format(name))


while guesses_made < 6:

    guess = int(input('Take a guess: '))

    guesses_made += 1

    if guess < number:

        print('Your guess is too low.')

    if guess > number:

        print('Your guess is too high.')

    if guess == number:

        break

if guess == number:

    print('Good job, {0}! You guessed my number in {1} guesses!'.format(name, guesses_made))

else:

    print('Nope. The number I was thinking of was {0}'.format(number))

我已将条目添加到 launch.json 中:


{

    "name": "Attach (Remote Debug)",

    "type": "python",

    "request": "attach",

    "localRoot": "${workspaceRoot}",

    "remoteRoot": "/home/pi/testdebug/",

    "port": 3000,

    "secret": "my_secret",

    "host":"localhost"

},


慕桂英546537
浏览 292回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答