小心点,这会很长。我的Python真的坏了,我不知道如何修复它。这一切都开始后,我的VSCODE pylance停止工作。我,出于某种原因,试图卸载我的Python,我在这里。所以基本上,我有一个脚本,它使用discord-webhook库来发送东西到我的Discord。我不知道我做了什么,但现在当我运行脚本时,一切都正常,所有函数和代码都正常,直到我到达webhook.execute()。我得到这个错误(顺便说一句,我在3.9.12上运行这个,但现在已经切换到3.10.0,它仍然是坏的):
Traceback (most recent call last):
File "e:\PythonProjects\Projects\DiscordWebhook.py", line 828, in <module>
webhook.execute()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_webhook\webhook.py", line 444, in execute
response = self.api_post_request()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_webhook\webhook.py", line 397, in api_post_request
return requests.post(
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 458, in send
self.cert_verify(conn, request.url, verify, cert)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 261, in cert_verify
OSError: Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users\Admin\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\cacert.pem
然后我的一些库卸载或不被识别,Python从PATH中删除,然后我尝试运行pip重新安装,我得到这个错误:
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'C:\Users\Admin\AppData\Local\Programs\Python\Python310\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\',
'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310\\DLLs\\',
'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python310',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00002fe8 (most recent call first):
<no Python frame>
现在我不能运行和脚本,运行任何Python相关的命令(pip,Python),如果我重新安装Python,同样的错误,安装一个新版本,同样的错误。以下是我尝试过的一些大的修复和事情:
Removed PYTHONHOME and PYTHONPATH system variables
Removed Python environment variable from my windows user profile
Uninstalled python 3.9.12 from my pc using Microsoft_Program_uninstall_reinstall_debugger.exe
Uninstalled all python versions from my pc using control panel and their files
sfc /scannow
After i get first error, i tried running python -m pip uninstall certifi
reinstalled VSCODE because i thought that was the problem
有人能帮帮忙吗。因为我现在不会写代码。
2条答案
按热度按时间qv7cva1a1#
1.重新安装Python:完全尝试uninstalling Python from your system,然后从the official Python website重新安装。
1.检查PATH环境变量:确保将Python安装目录添加到PATH环境变量中。当你安装Python时,安装程序会默认选择添加到环境变量。
1.通常,我们建议使用虚拟环境而不是全局环境。使用虚拟环境可以更容易地管理Python包。您可以阅读文档了解有关创建虚拟环境的更多详细信息。
k4ymrczo2#
结果我忘记删除一行代码,如下所示:
remove_all_zip_files(os.path.dirname(sys.executable))
这将删除指定路径中的所有文件夹和文件,但是,它将删除我的python安装中的所有文件夹和文件。这就是为什么找不到证书或名为encodings的模块的原因。很抱歉任何麻烦!