Python 脚本已锁定以在 VS 2015 中进行调试

Python Script locked for debug in VS 2015

我正在上 nucleai 课程。练习基于 python 脚本,我使用的是 Visual Studio 2015。在某些时候,我们必须使用库 nltk。我正在尝试调试我正在调用的一些代码(我有源代码)并且发生了一些非常奇怪的事情:断点有效,但我不能使用 F10 逐行跳转。它只是跳过所有脚本。我可以毫无问题地调试我的任何脚本,但不能调试库中的脚本。 所以我的问题是:"unlock" 脚本是否有任何选项,以便我可以逐行调试? 我是 python 的新手,在 google 上找不到任何类似的东西。我正在发布代码以防万一。 我要调试的函数是'Respond'

from __future__ import print_function

import re
import random
from nltk import compat

reflections = {
"i am"       : "you are",
"i was"      : "you were",
"i"          : "you",
"i'm"        : "you are",
"i'd"        : "you would",
"i've"       : "you have",
"i'll"       : "you will",
"my"         : "your",
"you are"    : "I am",
"you were"   : "I was",
"you've"     : "I have",
"you'll"     : "I will",
"your"       : "my",
"yours"      : "mine",
"you"        : "me",
"me"         : "you"
}

class Chat(object):
def __init__(self, pairs, reflections={}):
    self._pairs = [(re.compile(x, re.IGNORECASE),y) for (x,y) in pairs]
    self._reflections = reflections
    self._regex = self._compile_reflections()


def _compile_reflections(self):
    sorted_refl = sorted(self._reflections.keys(), key=len,
            reverse=True)
    return  re.compile(r"\b({0})\b".format("|".join(map(re.escape,
        sorted_refl))), re.IGNORECASE)

def _substitute(self, str):
   return self._regex.sub(lambda mo:
            self._reflections[mo.string[mo.start():mo.end()]],
                str.lower())

def _wildcards(self, response, match):
    pos = response.find('%')
    while pos >= 0:
        num = int(response[pos+1:pos+2])
        response = response[:pos] + \
            self._substitute(match.group(num)) + \
            response[pos+2:]
        pos = response.find('%')
    return response

def respond(self, str):
    # check each pattern
    for (pattern, response) in self._pairs:
        match = pattern.match(str)

        # did the pattern match?
        if match:
            resp = random.choice(response)    # pick a random response
            resp = self._wildcards(resp, match) # process wildcards

            # fix munged punctuation at the end
            if resp[-2:] == '?.': resp = resp[:-2] + '.'
            if resp[-2:] == '??': resp = resp[:-2] + '?'
            return resp

# Hold a conversation with a chatbot
def converse(self, quit="quit"):
    input = ""
    while input != quit:
        input = quit
        try: input = compat.raw_input(">")
        except EOFError:
            print(input)
        if input:
            while input[-1] in "!.": input = input[:-1]
            print(self.respond(input))

非常感谢任何帮助。 谢谢

编辑: 我解决了我的问题,但我还没有找到问题的解决方案。我正在使用 PyCharm (如第一条评论中所建议的那样),它就像一个魅力。我现在可以毫无问题地调试所有内容。根本没有文件修改。我倾向于认为这是 Python 用于 Visual Studio 的工具中的错误。

其他成员也遇到了类似的问题,我的建议是您可以使用 PyCharm 而不是 PTVS 作为解决方法。当然,您也可以从这个站点开始讨论(Q AND A)以获取 PTVS 工具:

https://visualstudiogallery.msdn.microsoft.com/9ea113de-a009-46cd-99f5-65ef0595f937