简体   繁体   中英

ModuleNotFoundError: No module named 'bs4' [sublime text 3]

Basically I am trying to run some simple code in sublime text 3 but when I try to run it it gives me the following error:

  File "/Users/ingodavila/Desktop/My Programming/scrape.py", line 1, in <module>
    from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'

I have tried installing it with pip3 and easy_install but it does not work. Whenever I try installing it it in terminal it keeps showing:

Requirement already satisfied: bs4 in ./opt/anaconda3/lib/python3.8/site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in ./opt/anaconda3/lib/python3.8/site-packages (from bs4) (4.9.1)
Requirement already satisfied: soupsieve>1.2 in ./opt/anaconda3/lib/python3.8/site-packages (from beautifulsoup4->bs4)

I tried running it in a jupyter notebook and it works but for sublime it keeps showing that 'nomodulefound' error. What can I do to solve this?

Are you running the code inside a virtual environment?

If you are, try this method:

  1. activate the env
  2. install the module (inside the virtualenv)
  3. run the code.

If the above doesn't work, try:

conda install bs4

It is probably because your Sublime text interpreter is different than your global one. I would recommend you using virtual environment instead of just installing modules globally. Check this one out on how to create venv . Once you set up your virtualenv and active it, you can just install packages and use them without any problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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