lagranges / people_also_ask

Python wrapper for google people-alos-ask
MIT License
100 stars 44 forks source link

No module named 'people_also_ask' #11

Closed hiddenchamp closed 8 months ago

hiddenchamp commented 2 years ago

Hello,

I am really new to python so there might be an easy solution to this. I just installed python yesterday (newest version) and now I tried out the PAA script.

I could install it but nothing happens when I run it. BTW I only have selenium. Do I need beautifulsoup for this?

solkad commented 2 years ago

Do you have multiple Python versions installed? If I make a file "test.py" and do "python test.py" I get a "ImportError: No module named people_also_ask" error, so I need to do "python36 test.py". You might need to do python3, or python38, or something like that. What does "python --version" give you? If it gives something like "Python 2.7.5" you might need to use Python 3.

BTW I only have selenium. Do I need beautifulsoup for this?

At the end when I install via "pip install people_also_ask ", it says beautifulsoup was installed, so you should already have it. Here is what pip outputs at the end for me:

Installing collected packages: urllib3, soupsieve, beautifulsoup4, people-also-ask
  Attempting uninstall: urllib3
    Found existing installation: urllib3 1.26.9
    Uninstalling urllib3-1.26.9:
      Successfully uninstalled urllib3-1.26.9
    Running setup.py install for people-also-ask ... done
Successfully installed beautifulsoup4-4.11.1 people-also-ask-1.0.0 soupsieve-2.3.2.post1 urllib3-1.24.3

Also you have to store the results as variables, then process the variable. The readme is a bit vague on that. And the "generate" functions return Generator objects, which you have to process with loops.

I put the following in a "test.py" file. It uses the pprint function to print the variables:

import people_also_ask
from pprint import pprint

#paaresult = people_also_ask.get_related_questions("coffee")
#paaresult = people_also_ask.get_related_questions("coffee", 5)
#paaresult = people_also_ask.get_answer("Why is coffee bad for you?")
#paaresult = people_also_ask.get_simple_answer("Why is coffee bad for you?")

#pprint(paaresult)

#paaresult = people_also_ask.generate_related_questions("coffee")
paaresult = people_also_ask.generate_answer("coffee")

for nextresult in paaresult:
        pprint(nextresult)

You can comment and un-comment the lines. You can pick one "paaresult" line from the "people_alsoask.get" section, and then un-comment the pprint(paaresult) line. Or pick one line from the "people_alsoask.generate" section, and un-comment the loop.

Hopefully that helps.

hqin2013 commented 2 years ago

Hi, I have the same error:

ModuleNotFoundError: No module named 'people_also_ask'

But I think i have installed the module, for when i run command "pip install people_also_ask ", get the information below, it really shows the module is installed for python3.9, why still get this error?! thank you

` root@localhost:/var/www/fastuser/data/www/domain.com# pip install people_also_ask Requirement already satisfied: people_also_ask in /usr/local/lib/python3.9/site-packages (1.1.0) Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.9/site-packages (from people_also_ask) (4.11.1) Requirement already satisfied: requests in /usr/local/lib/python3.9/site-packages (from people_also_ask) (2.28.1) Requirement already satisfied: jinja2 in /usr/local/lib/python3.9/site-packages (from people_also_ask) (3.1.2) Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.9/site-packages (from beautifulsoup4->people_also_ask) (2.3.2.post1) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.9/site-packages (from jinja2->people_also_ask) (2.1.1) Requirement already satisfied: charset-normalizer<3,>=2 in /usr/local/lib/python3.9/site-packages (from requests->people_also_ask) (2.1.0) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests->people_also_ask) (2022.6.15) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests->people_also_ask) (1.26.11) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests->people_also_ask) (3.3) WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

`

charliemday commented 1 year ago

Hi 👋 when you run pip freeze in your terminal this should give a list of all the Python packages installed, does people-also-ask==VERSION_NUMBER exist in the list?

Also when you run python --V what Python version are you getting?