-1

I am working under Windows 10, and I have several version of python, but I need to work under Python 3.8.10 (with pyenv shell 3.8.10 check the picture below).

I get this exception when I launch my code:

Exception has occurred: ModuleNotFoundError No module named 'statsmodels'

However, statsmodels has already been installed with pip (under the 3.10.8 MS version). Indeed, it works under 3.10.8 but not under 3.8.10.

So I have activated venv i.e. with this command ..venv\Scripts\activate, and I install again inside this virtual environnement.

Indeed, now I see statsmodels under c:\my_project_folder.venv\include\lib\site-packages

I have set $PYHTONPATH="path to the project folder" through system properties/advanced/emvironement variables

pyenv different version

Someone has an idea how to fix this exception ?

Al Bundy
  • 184
  • 1
  • 12

1 Answers1

2

However, statsmodels has already been installed with pip (under the 3.10.8 MS version). Indeed, it works under 3.10.8 but not under 3.8.10.

Different versions of python have different site-packages. When you choose the 3.8.10, python interpreter cannot get the packages that you installed in the 3.10.8's site-packages.

So the solution is to install the package again in your python 3.8.10 :

  1. Choose the Python 3.8.10 interpreter as you do in the picture
  2. Use the command pip install statsmodels in the cmd to install this package to 3.8.10's site-packages.
MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13