I'm using JupyterLab and I've found that it always uses my system's Python installation (version 3.9) instead of the installation of whatever conda environment I launch it from (3.10 in this case). Here is a minimal example of the problem:
In the terminal:
conda create --name Simplex python=3.10
conda activate Simplex
conda install jupyterlab
ipython kernel install --user --name=Simplex
jupyter lab
Hence JupyterLab has been launched in a conda environment with Python version 3.10, which I would have assumed means that the kernel would be using Python 3.10. However, when I run the following:
# Terminal Commands
!conda list python
!python -V
# Python Commands
import sys
print(f"Python Version {sys.version}")
The first query shows Python 3.10, but the others show Python 3.9. Furthermore, if I do something like int | str
in a code block in JupyterLab, I'll get:
"TypeError: unsupported operand type(s) for |: 'type' and 'type'"
Since this functionality was added in Python 3.10, that serves as further confirmation that I am indeed using Python 3.9 unconsensually. The problem persists if I explicitly tell JupyterLab to use the kernel "Simplex" that I created in my minimal example. If I run:
print(f"{sys.executable}")
I get:
/Users/baileyandrew/opt/anaconda3/bin/python
whereas when poking around Finder I think that my conda environment's Python is stored at;
/Users/baileyandrew/opt/anaconda3/envs/Simplex/bin/python3.10
I am using a Mac, and conda -V
gives the output conda 22.9.0
.
I assume that there is an issue with either JupyterLab or Conda in how they are pathing to find my python distribution, but unfortunately I am woefully out of my depth here. Any help would be appreciated. Using 3.9 is not an issue for me, but I'd really like to get to the bottom of this issue.