使用 Python3 的 Visual Studio Code 获取 nltk 证书验证失败错误

问题描述 投票:0回答:1

我收到此错误。正如你所看到的,我按照他们的指南在我的代码中导入了 nltk 和 nltk.download 。:

[nltk_data] Error loading words: <urlopen error [SSL:
[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data]     unable to get local issuer certificate (_ssl.c:1000)>

我的代码:

import re # To remove regular expressions. Like ? ! . ,
import tkinter as tk # This is a graphical UI
from tkinter.scrolledtext import ScrolledText # Widget

import nltk
nltk.download('words') # Check wether a word is valid
from nltk.corpus import words



class SpellingChecker:

    def __init__(self):
        self.root = tk.Tk() # tk.Tk refers to a class within the Tkinter module, which is a standard GUI
        self.root.geometry("600x500")

        self.text = ScrolledText(self.root, font=("Helvetica", 14))
        self.text.bind("<KeyRelease>", self.check) # To check words whenever we release a key
        self.text.pack()

        self.old_spaces = 0 # By default we have 0 whitespaces

        self.root.mainloop() # To get the GUI running


    def check(self, event):
        content = self.text.get("1.0", tk.END)  # 1.0 is the first character, 1.1 is the second character, 1.2 is the third character etc.  # tk.END this gives the full content of the text box
        space_count = content.count(" ") # Count the white spaces

        if space_count != self.old_spaces: # If space count is not the same, != as self.old_spaces
            self.old_spaces = space_count

            for tag in self.text.tag_names():
               self.text.tag_delete(tag)
            
            for word in content.split(" "):
                if re.sub(r"[^\w]", "", word.lower()) not in words.words():
                    position = content.find(word)
                    self.text.tag_add(word, f"1.{position}", f"1.{position + len(word)}")
                    self.text.tag_config(word, foreground="red")
        
SpellingChecker()

我使用的是 MacOS,并且安装了 Python3。

寻找答案。

我尝试重新添加它们,例如nltk3,检查论坛,视频。什么也没有。

python nltk errno
1个回答
0
投票

使用VPN,然后在顶部添加一些证书代码。

© www.soinside.com 2019 - 2024. All rights reserved.