Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixing my Python installation(s) & Jupyter Notebook

I once downloaded tools (Python 2, Visual Studio, Virtual Box, etc.) however now have my jupyter notebook and any other notebook I use default to the old/original version of python & anaconda that I had initially installed.

I already tried removing and uninstalling any old downloads/versions and I updated everything in my terminal including my notebook using:

python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\programdata\anaconda3\lib\site-packages (20.0.2)

However my notebook still tells me the following:

You are using pip version 9.0.1, however version 20.0.2 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.

The same happens when I try installing the latest version of seaborn (to help visualize and chart with matplotlib) via the terminal. When I check which is the latest version I have in my terminal, it shows the following:

$ pip show seaborn
Name: seaborn
Version: 0.10.0
Summary: seaborn: statistical data visualization
... 
Location: c:\programdata\anaconda3\lib\site-packages
Requires: scipy, matplotlib, pandas, numpy

However, when I print/check in my notebook it reads:

import seaborn as sns
sns.__version__
0.7.1

Lastly, when I run the following code in my notebook it reads:

import sys
sys.version
3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)]

I checked to see the executable location for Python in my Jupyter notebook and got back the following:

sys.executable
C:\\Users\\myusername\\.conda\\envs\\PythonData\\python.exe'

and I checked to see the available kernels for Jupyter in my terminal:

$jupyter kernelspec list
Available kernels:
>python3    C:\ProgramData\Anaconda3\share\jupyter\kernels\python3

Based on the example below, I believe the executable location for my notebook(s) defaults to an older version of Python2 that was initially downloaded.

For Python2:

$ python
import sys
print sys.executable

The output is: /usr/bin/python

For Python3:

$ python3
import sys
print (sys.executable)

The output is: /usr/bin/python3

I know I can wipe out my computer and install everything from scratch but that is not ideal for me.

like image 768
A A Avatar asked Dec 07 '25 12:12

A A


2 Answers

Try to update the anaconda notebook from the Anaconda Navigator. Click - Environments - Click - Update Index.. Select the new packages and give update. Try this method

like image 200
vivek rajagopalan Avatar answered Dec 09 '25 00:12

vivek rajagopalan


First off, wipe python2 completely. It's end of life and you should invest time to upgrade your old code if you really need it. Second, might as well install Python 3.8 or Miniconda3 (I suspect you don't require all of Anaconda)

Regarding the commands you've ran, you appear to be showing both Windows and Unix paths, which is very confusing but jupyter only knows about python3 installation, not your old one.

If you really don't want to completely start over, use Jupyter docker containers and mount your code within them. In the end, it'll be much simpler to manage python versions and it won't clutter your host OS.

But if you do not want to use Docker, you can look at using pyenv for Python version management (though, I've not tried it on windows, so YMMV)

like image 31
OneCricketeer Avatar answered Dec 09 '25 02:12

OneCricketeer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!