Struggle to install and use Advertools package in a Jupyter notebook

Hi all, I would like to explore the Advertools package (details here: https://advertools.readthedocs.io/en/master/) which is an online marketing and analysis tools. I’m interested in exploring one function in particular which is the sitemap_to_df function and I’d like to do so in a Jupyter notebook.

The code I would like to explore is:

import advertools as adv
import pandas as pd
my_sitemap = adv.sitemap_to_df('https://www.bbc.com/sitemaps/https-sitemap-com-archive-1.xml')

However I’m struggling to install the package at the first place…

I’m aware that still being a beginner in Python, I must be missing crucial basic knowledge of how to actually run scripts and installing packages as I’ve been mostly learning on the Dataquest platform.

Below are some of the errors I get:

install advertools

File “”, line 1
install advertools
^
SyntaxError: invalid syntax

import advertools as adv
import pandas as pd
my_sitemap = adv.sitemap_to_df('https://www.bbc.com/sitemaps/https-sitemap-com-archive-1.xml')

AttributeError Traceback (most recent call last)
in
----> 1 my_sitemap = adv.sitemap_to_df(‘https://www.bbc.com/sitemaps/https-sitemap-com-archive-1.xml’)

AttributeError: module ‘advertools’ has no attribute ‘sitemap_to_df’

Thanks for your help!

1 Like

Are you doing this locally? If so open Anaconda Prompt and run conda install advertools.


image

Thereafter you can also launch jupyter notebook from the prompt and this code should work.
image

1 Like

This is not valid command.

Use

pip install advertools

Or if you have anaconda environment installed then you can use conda install advertools as @masterryan.prof said.

Hi both @masterryan.prof and @DishinGoyani, thanks for replying to my query. What you wrote makes sense to me, however I can’t really see an Anaconda prompt on Mac…

I’m sure it must be pretty straightforward but this is what I see

Thanks again for your support!

@coquillette: Under Environments on the left pane > base(root) > open terminal. Unless you created another environment like mine (opencv).

You may choose to check out this guide to help familarise yourself with the environment.

@coquillette: Just following up, did it work for you?

Hi @masterryan.prof, not really, I’m still having roadblocks. Here are the steps I followed:

I installed the advertools package using the conda install command in the Anaconda terminal as suggested. However, after running the code I wanted to explore in a Jupyter notebook, I get this error:

AttributeError: module 'advertools' has no attribute 'sitemap_to_df'

Using the command conda list, I can see that an old version of the Advertools package was installed which may not have the specific attribute I’d like to use.
image

Back to the Anaconda terminal, I used the following command to try to install the latest package version: conda install advertools=0.10.7 which resulted in the following message:

PackagesNotFoundError: The following packages are not available from current channels:
- advertools=0.10.7
Current channels:
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://conda.anaconda.org/conda-forge/osx-64
- https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you’re looking for, navigate to https://anaconda.org and use the search bar at the top of the page.

I then went to http://anaconda.org, found the package but it does not show the latest version https://anaconda.org/edabbas/advertools

And now I’m not too sure what’s next!

@coquillette:

Try seeing if uninstalling the package helps:

conda remove advertools

followed by the reinstallation

conda install advertools=0.10.7

Thanks for your support @masterryan.prof but I get the same error

PackagesNotFoundError: The following packages are not available from current channels:
- advertools=0.10.7
Current channels:
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://conda.anaconda.org/conda-forge/osx-64
- https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you’re looking for, navigate to https://anaconda.org and use the search bar at the top of the page. 

I think I need t research how channels work…

@coquillette:

Could you try the solutions in these 2 articles and let me know if they worked for you? Thanks!


If not maybe you could try creating a new environment and downloading the packages there.

In anaconda prompt:

conda create --name <env_name>
conda activate <env_name>
conda install -c anaconda jupyter 
conda install advertools=0.10.7
1 Like

@coquillette

Thanks for your interest, I’m the author of advertools.

advertools is only available on pip, so pip install advertools is the only command that would work.

The conda thing was just a test, but it’s not working.

Happy to answer any questions on the package, and sorry for any confusion.

Good luck!
Elias

2 Likes