问题
When I use IDLE the code "import statistics" runs, however when I use sublimetext while other packages, such as matplotlib, can be imported I cannot import the statistics module. It gives me this error code:
import math
import matplotlib
import statistics
I expect nothing to happen on the screen, but in the command line it spits out. Note that the first two lines of code did work.
ImportError: No module named statistics
[Finished in 1.2s with exit code 1]
[shell_cmd: python -u "/Users/Ivan/Desktop/Math file.py"]
[dir: /Users/Ivan/Desktop]
[path: /opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin]
回答1:
Go to the command prompt.
Type
pip3 install update
If that doesn't work try
pip3 install --upgrade pip
Then type
pip3 install statistics
at the command prompt.
This has solved my similar problems in the past :)
来源:https://stackoverflow.com/questions/53965561/import-statistics-fails-to-run