Python ImportError no module named statistics after downloading

31,726

Solution 1

Statistics "A Python 2.* port of 3.4 Statistics Module" (PyPI).

If you use 2.7.9, you will have pip installed, and pip install statistics within the 2.7 directory should install the module for 2.7 (I am not a pip or virtual machine expert, so might be slightly off.)

Solution 2

It comes pre-installed in python --Version 3. To import in python version 2 in Ubuntu, open Terminal and type

sudo pip install statistics 

Enter your password and it will get installed.

Ps: you need to have pip already installed.

Share:
31,726
Tia Alexa
Author by

Tia Alexa

Updated on November 30, 2020

Comments

  • Tia Alexa
    Tia Alexa over 3 years

    I'm trying to run my code and I don't know what specific package I need in order to get my import statement to work. Below is my header and I keep getting an error saying ImportError no module named statistics. I have looked at a bunch of different pages to see where I can download a solution, but I am trapped. I know my code works because I ran it on my schools lab. If anyone can help, that' be great! Just note I am a beginner and am using Linux on my virtual machine with Python 2.7

    import sys
    import requests
    import matplotlib.pyplot as plt
    import statistics as stat  
    
  • Jon Kiparsky
    Jon Kiparsky over 9 years
    If you want to use this package in python 2, I'm not sure what to tell you - there are certainly stats packages for 2, but not this one. As a side note, I typically have python 2.mumble installed as python and python 3.latest as python3 - if you set yourself up this way, you can play with this package but still use 2.7 for your regular work.