DEV Community

Marco
Marco

Posted on

How to determine which Python version your Jupyter notebook is using

Have you ever spent an incredible amount of time trying to understand which version of Python your Jupyter Notebook is using, or how to install a library on it? The solution is actually quite simple.

All you need to do is run the following code block in your Jupyter Notebook:

import sys
print(sys.executable)
print(sys.version)
print(sys.version_info)
Enter fullscreen mode Exit fullscreen mode

This will return information about the version of Python being used, as shown below:

/usr/local/opt/python@3.9/bin/python3.9
3.9.16 (main, Dec  7 2022, 10:15:43) 
[Clang 14.0.0 (clang-1400.0.29.202)]
sys.version_info(major=3, minor=9, micro=16, releaselevel='final', serial=0)
Enter fullscreen mode Exit fullscreen mode

Ah!! Now everything is clear! You can also find pip3.9 in the /usr/local/opt/python@3.9/bin/ directory, and there is also pip3.9 that you can use to install library like :

/usr/local/opt/python@3.9/bin/pip3.9 install dotenv

Stay tuned for future improvements and next episodes on how to use an environment in Jupyter Notebook

Top comments (0)