Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python ImportError no module named statistics after downloading

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  
like image 646
Tia Alexa Avatar asked Dec 20 '22 08:12

Tia Alexa


2 Answers

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.)

like image 129
Terry Jan Reedy Avatar answered Dec 28 '22 09:12

Terry Jan Reedy


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.

like image 41
Navneet K Avatar answered Dec 28 '22 09:12

Navneet K