简体   繁体   English

导入“不和谐”无法解决

[英]Import "discord" could not be resolved

I have programmed a discord bot with python and I installed all discord.py libraries.我用 python 编写了一个 discord 机器人,并安装了所有 discord.py 库。 the problem is when I run the script it said no module found but I already install everything the errors are: in the following picture enter image description here问题是当我运行脚本时它说没有找到模块,但我已经安装了所有错误:在下图中,在此处输入图像描述

also the same error appear for the libraries like the photos above any help??像上面的照片这样的库也会出现同样的错误,有什么帮助吗?

I was having a lot of troubles with stuff I got with pip install and they were installed successfully, but when I tried to import them, they didn't import我在安装 pip 时遇到了很多麻烦,它们已成功安装,但是当我尝试导入它们时,它们没有导入

I found out that for me, some of the installs get installed to a separate folder, and not the correct folder that they need to be in to import.我发现对我来说,一些安装被安装到一个单独的文件夹,而不是它们需要在其中导入的正确文件夹。

If you try installing it again with pip install, then it will say you already have it installed and it will give you the location where the file is, and I copied the files from there and pasted them into the correct location which is (on windows)如果您尝试使用 pip install 再次安装它,那么它会说您已经安装了它,它会给您文件所在的位置,我从那里复制文件并将它们粘贴到正确的位置,即(在 Windows )

C:\Users{Username}\AppData\Local\Programs\Python{Python Version}\Lib\site-packages C:\Users{用户名}\AppData\Local\Programs\Python{Python 版本}\Lib\site-packages

I was trying to find a place to share this and this was the closest to the issue, so I hope it helps!我试图找到一个分享这个的地方,这是最接近问题的地方,所以我希望它有所帮助!

I had the same issue.我遇到过同样的问题。 The solution is to change the Python Interpreter.解决办法是改Python解释器。 You can do it by Ctrl + Shift + P and choose "Python: Select Interpreter" in visual studio code.您可以通过Ctrl + Shift + P并在 Visual Studio 代码中选择“Python:Select Interpreter”。

I was having a similar issue in VS code with a file containing a function and another file that was trying to import that function.我在 VS 代码中遇到了类似的问题,其中一个文件包含 function 和另一个试图导入该 function 的文件。 My problem was that although they were saved in the same folder I hadn't opened that folder in VS code.我的问题是,虽然它们保存在同一个文件夹中,但我没有在 VS 代码中打开该文件夹。

Simply going File>Open Folder... and then navigating to the folder containing the file with the function and the file that I wanted to import the function from resolved the issue.只需转到文件>打开文件夹...,然后导航到包含 function 文件的文件夹和我想从中导入 function 的文件即可解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM