0

I am trying to upgrade scipy to solve this problem. I go to the Command Prompt, type

pip uninstall scipy
pip install scipy

and the output is "Successfully installed scipy-1.9.0". However, if I go to Jupyter and type:

import scipy
print(scipy.__version__)

the output is 1.7.3. Does anybody know what's going on? Total noob here. Thanks!

1 Answers1

2

The comment by @user:1397946is right, you are installing scipy to the wrong python environment. An easy way to install packages in the 'right' environment (i.e. the one used by jupyter) is to use install it directly from inside Jupyter:

%pip install scipy

By adding the percentage sign in front you can run command line arguments from inside the Jupyter environment (see this post). This way it should install it to the right environment.

Edit: @DominikStańczak is right. The percentage sign is the better option!

  • 3
    Are you 100% sure about this? I thought `!` in Jupyter just passes the command to bash. The way I usually do pip installs from Jupyter is `%pip install`, via the [built-in magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html). – Dominik Stańczak Jul 29 '22 at 16:56
  • You are correct @DominikStańczak . Using the magic commands is now best practice. It will insure it goes to the right environment, which the exclamation point alone won't do. Those interested can see [here](https://discourse.jupyter.org/t/why-users-can-install-modules-from-pip-but-not-from-conda/10722/4?u=fomightez) for more about the `%pip` and `%conda` magic commands now in Jupyter. – Wayne Jul 29 '22 at 20:38