I am using :
- Python 3.6.6
- Mac OS High Sierra 10.13.6
and the following website to help me install pytrends https://pypi.org/project/pytrends/
I am following the instructions to download pytrends and installed the requirements to run pytrends "requests, lxml, & pandas". Here are the instructions
- Install pytrends
pip install pytrends
- Connect pytrends to google
from pytrends.request import TrendReq
pytrends = TrendReq(hl=’en-US’, tz=360)
but I get the following error
File "<ipython-input-1-e31d93dc256d>", line 2
pytrends = TrendReq(hl=’en-US’, tz=360)
^ SyntaxError: invalid character in identifier
so I researched for information to help me and found a code that worked better for me from https://github.com/GeneralMills/pytrends/blob/master/README.md
from pytrends.request import TrendReqpytrends = TrendReq(hl='en-US', tz=360)
but I received the following error
ModuleNotFoundError Traceback (most recent call last) <ipython-input-9d1eaf7e6778a>in <module>() ---->
1 from pytrends.request import TrendReq
2
3 pytrends = TrendReq(hl='en-US', tz=360) ModuleNotFoundError: No module named 'pytrends'
I ran the above mentioned code in Jupiter labs. My guess is that I have to import pytrends in Jupiter lab. I installed pytrends but through terminal not Jupyter labs. I will try !pip3 install pytrends
in Jupiter lab. I got this idea by reading an issue someone has from
https://github.com/GeneralMills/pytrends/issues/248
In addition to link above, I found two other relevant questions on stack overflow that might help me solve this issue :
Jupyter Notebook: no module named pandas
numpy & pandas 'ModuleNotFoundEror' in Jupyter notebook (Python 3)