hi i'm trying to learn web scraping but this code gives me an error i looked it up why and tried what they said but still doesn't work. i have a windows in my mac too and i tried in there and it worked but in macOS it doesn't work.
ok this is the code i'm trying to execute:
#!/usr/bin/env python3
import bs4 as bs
import urllib.request
sauce = urllib.request.urlopen("https://pythonprogramming.net/parsememcparseface/").read()
soup = bs.BeautifulSoup(sauce, "lxml")
print(soup)
this is the error i get:
`Traceback (most recent call last):
File "/Users/aaa/Desktop/import bs4 as bs.py", line 4, in <module>
import urllib.request
ImportError: No module named request
[Finished in 0.4s with exit code 1]
[shell_cmd: python -u "/Users/aaa/Desktop/import bs4 as bs.py"]
[dir: /Users/aaa/Desktop]
[path:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin] `
I looked this up and tried what they are saying
ImportError: No module named requests
but terminal says:
Requirement already satisfied: requests in
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (2.23.0)
Requirement already satisfied: idna<3,>=2.5 in
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from
requests) (2.9)
Requirement already satisfied: certifi>=2017.4.17 in
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from
requests) (2019.11.28)
Requirement already satisfied: chardet<4,>=3.0.2 in
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from
requests) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from
requests) (1.25.8)
I deleted this #!/usr/bin/env python3
from my code and tried again and still says the same thing.
and a couple of months ago I might mess up those "path" things by an accident.(i was trying to solve a bug or smt like that i copied and pasted some things to the terminal than some guy said i shouldn't be doing that i might do smt wrong. but i haven't noticed anything yet and i'm not sure what that thing was) i'm not even sure what that means i'm that new to programming. I don't really know it feels like that might be the problem.