简体   繁体   English

Pylint 导入无法解决

[英]Pylint import could not be resolved

I develop on WSL ubuntu with vscode and python3.10.我使用 vscode 和 python3.10 在 WSL ubuntu 上开发。 I installed tweepy but vscode returns this error, and this does not allow suggestions by pressing CTRL+BACKSPACE.我安装了 tweepy 但 vscode 返回此错误,并且这不允许通过按 CTRL+BACKSPACE 的建议。 The error is as follows:错误如下: 在此处输入图像描述

The interpreter is already set to python3.10, and in setting.json I have this:解释器已经设置为 python3.10,在 setting.json 我有这个:

{
    "python.linting.pylintEnabled": false,
    "python.linting.enabled": true
}

This problem occurs every time, and I really don't know how to solve it, would you have any ideas about this?每次都会出现这个问题,真的不知道怎么解决,请问您有什么想法吗? Even trying to change python version there is no change.即使尝试更改 python 版本也没有任何变化。

These are the python-related extensions installed: Python, Pylance, IntelliCode这些是安装的与 python 相关的扩展:Python、Pylance、IntelliCode

If I try to run the code (with python3.10) I get the error: ModuleNotFoundError: No module named 'tweepy', this problem, however, does not occur in python3.7如果我尝试运行代码(使用 python3.10)我得到错误:ModuleNotFoundError: No module named 'tweepy',但是,这个问题在 python3.7 中不会发生

Both Pylance and Python say that tweepy isn't installed. Pylance 和 Python 都说没有安装 tweepy。 That means it's almost certainly not installed in the environment you're using.这意味着它几乎肯定没有安装在您使用的环境中。

It sounds like there are multiple Python installations or virtual environments on your machine.听起来您的机器上有多个 Python 安装或虚拟环境。 My guess is that the one with Python 3.7 has tweepy and the one with Python 3.10 does not.我的猜测是使用 Python 3.7 的那个有 tweepy,而使用 Python 3.10 的那个没有。 To find out more, we'd need to know how you installed Python and its different versions.要了解更多信息,我们需要知道您是如何安装 Python 及其不同版本的。 There are many ways to do that and they have little in common.有很多方法可以做到这一点,但它们几乎没有共同点。

However, that's probably not necessary: just switch to the Python 3.10 environment and install tweepy the same way you did before, eg with pip install tweepy if you usually use pip for installing modules from PyPI.但是,这可能不是必需的:只需切换到 Python 3.10 环境并以与之前相同的方式安装 tweepy,例如,如果您通常使用 pip 从 PyPI 安装模块,则使用pip install tweepy

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

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