ImportError: No module named mixpanel_api

  • 2 July 2020
  • 1 reply

Badge +1

Hi there!


I’m new to python and I’ve been trying to follow the directions to install the mixpanel_api so I can update people profiles (in bulk). I keep getting the following error:

ImportError: No module named mixpanel_api


I’ve installed mixpanel using pip, i’ve pasted my code below:


from mixpanel_api import Mixpanel

m = Mixpanel('API Secret', 'Token')

if __name__ == '__main__':

    credentials = {

        'API_secret':’INSERT HERE’,

        'token':'INSERT HERE',



    m = Mixpanel(credentials['API_secret'])

Am I missing a step?

1 reply

Userlevel 5
Badge +3

Hi @robyn-dunne —


I confirmed with Mixpanel Support that you resolved this issue — but for anyone stumbling on this post in the future,  here are some suggested steps to take:


Generally when I see this ImportError: No module named mixpanel_api ​, it leads me to believe that the module wasn't properly installed or perhaps you're using Python3 and not Python2. The API module only support Python2. You can check which version of Python you're using by calling python --version​ in your terminal. If you have Python3 installed, you'll need to install Python2. 

  1. The first step is to confirm what version of Python you’re using.
  2. The next step is to confirm the  environment you are installing packages in
  3. Next, take a look into the code snippet you are installing — you only need these first two lines to authenticate:
from mixpanel_api import Mixpanelm = Mixpanel('INSERT_YOUR_API_SECRET_HERE', 'INSERT_TOKEN_HERE')

This code block below is another form of authenticating but you don't need it if you filled in the above. 

if __name__ == '__main__':     credentials = {         'API_secret':’INSERT HERE’,         'token':'INSERT HERE',         }     m = Mixpanel(credentials['API_secret'])


​​​​​​​​​​​​​​Once you've authenticated, you can write additional code depending on what you want to do. For example, the following code copied from our Mixpanel API Module's Github page shows you an example of how to export people:

selector = '(("Albany" in properties["$city"]) and (defined (properties["$city"])))' parameters = { 'selector' : selector}m.export_people('people_export.txt',parameters,timezone_offset=-8)