9

I'm trying to use the PyTrends module that is available on Github (here). To use this script I need to install the fake-useragent module with:

pip install fake-useragent

However, every time I import the file and attempt execute commands in console, I get the following error:

>>> from pytrends2.pyGTrends import pyGTrends
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pytrends2.py", line 18, in <module>
    from fake_useragent import UserAgent
ImportError: No module named fake_useragent

I've tried different things and had no luck. When trying to make sure the dependency modules are installed with:

pip install pyyaml ua-parser user-agents

... I get the following:

abraham@abraham-Inspiron-3521:~$ sudo pip install pyyaml user-agents
Downloading/unpacking pyyaml
  Downloading PyYAML-3.11.tar.gz (248kB): 248kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pyyaml/setup.py) egg_info for package pyyaml

Downloading/unpacking user-agents
  Downloading user_agents-1.0.1-py2-none-any.whl
Downloading/unpacking ua-parser (from user-agents)
  Downloading ua_parser-0.5.0-py2-none-any.whl (66kB): 66kB downloaded
Installing collected packages: pyyaml, user-agents, ua-parser
  Running setup.py install for pyyaml
    checking if libyaml is compilable
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
    build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory
     #include <yaml.h>
                      ^
    compilation terminated.

    libyaml is not found or a compiler error: forcing --without-libyaml
    (if libyaml is installed correctly, you may need to
     specify the option --include-dirs or uncomment and
     modify the parameter include_dirs in setup.cfg)

Successfully installed pyyaml user-agents ua-parser
Cleaning up...
Cheche
  • 1,456
  • 10
  • 27
ATMA
  • 1,450
  • 4
  • 23
  • 33
  • I clicked on the link you gave and it said to do `sudo pip install pytrends`. is this the right module? – Jonah Fleming Nov 04 '15 at 09:44
  • 2
    Your pyyaml installation failure can be addressed by installing the right development packages; see [this answer](https://stackoverflow.com/a/37134143/1748148) for details. Once you've sorted that out, you might have more luck. – gowenfawr Feb 10 '18 at 17:32
  • Possible duplicate of [Why fatal error: 'yaml.h' file not found when installing PyYAML?](https://stackoverflow.com/questions/34164651/why-fatal-error-yaml-h-file-not-found-when-installing-pyyaml) – kabanus Nov 10 '18 at 10:44

1 Answers1

3

You probably want to install the development libraries for your Linux first. Make sure you have all development packages installed.

If you do operate on Ubuntu try to run this first

sudo apt-get install gcc libyaml-dev libpython2.7-dev 

You will be able then to install your required python libraries.

pip install pyyaml ua-parser user-agents fake-useragent

Best wishes

Stefano
  • 453
  • 4
  • 18