1

I am trying to statsmodel. I installed statsmodel using the pip install statsmodels in the CMD terminal.

However every time I try to run the import statsmodels.api as sm in Spyder I get the following error:

ModuleNotFoundError: No module named 'statsmodels'

Do I have to add Spyder as into Windows Path to get access to the statsmodels library? Why is statsmodels not loading? Here is proof that I have it installed:

C:\Users\Jessica>pip list
Package         Version
--------------- -------
numpy           1.21.4
pandas          1.3.4
patsy           0.5.2
pip             21.3.1
python-dateutil 2.8.2
pytz            2021.3
scipy           1.7.2
setuptools      57.4.0
six             1.16.0
statsmodels     0.13.0
Daniel Walker
  • 6,380
  • 5
  • 22
  • 45
jessica
  • 1,325
  • 2
  • 21
  • 35
  • 1
    Check if your global python version and project python version the same (Are you using virtual env or pyenv?) – rzlvmp Nov 07 '21 at 04:12
  • How do I check for that? – jessica Nov 07 '21 at 05:39
  • 1
    run `python --version` from cmd and `import sys; print(sys.version)` inside Spyder. And check is it the same – rzlvmp Nov 07 '21 at 08:08
  • My Python version is 'Python 3.10.0'. My System version is 3.7.9 (Aug. 17, 2020). So they are not the same. Should they be the same? – jessica Nov 07 '21 at 15:11
  • 3
    `Should they be the same?` → No. Correct question is: `Should I use specific pip for 3.10 if multiple pips (and pythons) installed on my OS` → Yes. Exact pip for exact python. Many pythons == many pips. Learn how to manage multiple pythons on one OS. [1](https://stackoverflow.com/questions/4583367/how-to-run-multiple-python-versions-on-windows), [2](https://www.freecodecamp.org/news/installing-multiple-python-versions-on-windows-using-virtualenv/), [3](https://levelup.gitconnected.com/how-to-install-and-manage-multiple-python-versions-on-windows-10-c90098d7ba5a) – rzlvmp Nov 08 '21 at 03:04

1 Answers1

0

Simply run:

python -m pip install statsmodels

James
  • 48
  • 7