0

I have a Jupyter notebook running inside an Anaconda virtual environment that won't recognize the statsmodels package. I've used both pip and conda, and I've reinstalled the whole environment several times in between restarting my computer. As you can see in this link, both pip and conda show that it is installed. However, I continue to get this error:

---> 43     import statsmodels.api as sm

ModuleNotFoundError: No module named 'statsmodels'

At first I thought it was the kernel, but that wouldn't explain why every other package I've installed is recognized properly.

The only thing I haven't done is tried it on another computer (I'm running Windows 10 x64). I just want to know if anyone can see something that I'm missing before I do so.

Thanks!

Edit: I've tried the following commands to install it:

pip install statsmodels
conda install -c conda-forge statsmodels
conda install statsmodels

I've tried using each command individually, making sure to uninstall the previous installation. I've tried using only two at a time, with the same methodology. I've tried every permutation of the above installations, with a computer restart in between. I don't think the problem is that it's not installing. I have no clue why but Jupyter notebooks just isn't recognizing this one package.

I'm running all of my commands from an Anaconda command prompt, and I make sure to activate my focal virtual environment. I also run Jupyter lab by typing it directly into the command prompt and hitting enter (I make sure I've activated my environment).

I'll try running it on a different OS and update.

John Richfield
  • 101
  • 1
  • 9
  • You should add it with Conda. I would believe what I see. Is it possible that the notebook is not pointing to the environment where the package was installed? – duffymo May 21 '22 at 00:21

1 Answers1

0

Thanks duffymo! My notebook wasn't using the correct kernel. I thought all I needed to do was run Jupyter lab from my virtual environment, but it needs to be purposefully added. I followed the directions shown here to add my conda environment to Jupyter lab:

How to add conda environment to jupyter lab

John Richfield
  • 101
  • 1
  • 9