This was my weird place on a Mac M2:
- Is Python environment correctly selected on the notebook? yes
- Is Python environment correctly selected on the integrated terminal? yes
- Does the Terminal recognise Python environment? yes
- Can I install libraries from the activated Terminal? yes
- Do I find the libraries when loading them in the jupyter notebook or in a python session? no, libraries are missing, even if they are installed with the correct activated environment.
So I figured out (after 20 minutes...!) that the bug is in the VSCode integrated terminal.
With a conda virtualenv called notes
I have the following:
- Integrated terminal of VsCode
(notes) $ which python
/Users/zzz/opt/anaconda3/envs/notes/bin/python
(notes) $ which pip
/Library/Frameworks/Python.framework/Versions/3.11/bin/pip # WRONG!!
(notes) $ which python
/Users/zzz/opt/anaconda3/envs/notes/bin/python
(notes) $ which pip
/Users/zzz/opt/anaconda3/envs/notes/bin/pip # CORRECT!!
For some reason VsCode is overriding pip
(or pip3
) to the one pointing at the library frameworks. The installed libraries are all installed in the Framework python, and they are not found when attempting to load them from the conda notes environment, as nothing had been installed there.
I could not find any better solution than avoid using the VScode terminal and use iterm instead.