简体   繁体   English

用于 bs4 的 Visual Studio Code 中的导入错误

[英]Import error in Visual Studio Code for bs4

I am having a huge problem with my Visual Studio Code and importing, really any modules I have installed.我的 Visual Studio Code 和导入(实际上是我安装的任何模块)都存在很大问题。

For example, recently I have installed BeautifulSoup4, however Visual Studio Code doesn't seem to want to import it, yet when I import it through something like idle or python in cmd or powershell it works completely fine.例如,最近我安装了 BeautifulSoup4,但是 Visual Studio Code 似乎不想导入它,但是当我通过 cmd 或 Z2F2D399F0EA8844859FE5514B304733 中的空闲或 python 之类的东西导入它时,它完全可以正常工作。

I am installing this by using pip;我正在使用 pip 安装它; I've tried pip install bs4, pip install BeautifulSoup4, pip install beautifulsoup4.我试过 pip 安装 bs4,pip 安装 BeautifulSoup4,pip 安装 beautifulsoup4。 Everytime it says it is installed and satisfied however in Visual There Seems to be a persisting problem.每次它说它已安装并满足但在 Visual There 似乎是一个持续存在的问题。

I have tried uninstalling bs4 and reinstalling it however this doesn't seem to work.我已经尝试卸载 bs4 并重新安装它,但这似乎不起作用。

This is what I am writing:这就是我正在写的:

from bs4 import BeautifulSoup

This is the output I get in Visual Studio Code:这是我在 Visual Studio 代码中得到的 output:

Traceback (most recent call last):
  line 1, in <module>
    from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'

However when I run this through a python terminal it works completely fine and imports as it should.但是,当我通过 python 终端运行它时,它可以正常工作并按应有的方式导入。

I had the same issue and resolved it using the Anaconda package and Jupyter Notebook.我遇到了同样的问题,并使用 Anaconda package 和 Jupyter Notebook 解决了它。 Downloaded the package, installed it, and had the same issues while working with VS Code.下载 package,安装它,在使用 VS Code 时遇到了同样的问题。 Used Anaconda and it worked flawlessly.使用 Anaconda 并且它工作完美。

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

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