So I'm trying to execute this basic Python script in Terminal (Mac) but it fails over when it's not able to find module.
Ran the same code into repl.it and works just fine so it's something on my machine which Python doesn't like.
Have attempted to install requests via:
pip3 install requests
But that fails over with:
m@mo-testmbp ~ % pip3 install requests Traceback (most recent call last): File "/Library/Developer/CommandLineTools/usr/bin/pip3", line 10, in sys.exit(main()) TypeError: 'module' object is not callable
Python script:
import requests
from random import randint
url = 'https://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain'
r = requests.get(url)
text = r.text
individual_words = text.split()
random_num = randint(0,len(individual_words))
print(individual_words[random_num] + str(random_num))
The code script fails with:
m@mo-testmbp ~ % /usr/bin/python3 "/Users/m/OneDrive - Mo/Training/Coding-mojoMac/Python/username_gen.py" Traceback (most recent call last): File "/Users/m/OneDrive - Mo/Training/Coding-mojoMac/Python/username_gen.py", line 1, in import requests ModuleNotFoundError: No module named 'requests'
requestsusing pip3 on the terminal of your computer, instead os VS Code? Otherwise perhaps try to reinstall pip3? - bastantoinerm -rfingrequests) - Mateen Ulhaqsudo. - Mateen Ulhaq