9

I upgraded to Ubuntu 24.04 LTS today. I am facing issues to deal with the python packages. I tried to install with pip, but got this error related to externally-managed-environment. Then I tried with pipx to install a few packages. The pipx list is showing like the following

venvs are in /home/raf/.local/share/pipx/venvs
apps are exposed on your $PATH at /home/raf/.local/bin
manual pages are exposed at /home/raf/.local/share/man
   package h5py 3.11.0, installed using Python 3.12.3
    - f2py (symlink missing or pointing to unexpected location)
    - numpy-config (symlink missing or pointing to unexpected location)
   package ipykernel 6.29.5, installed using Python 3.12.3
    - debugpy
    - ipython
    - ipython3
    - jupyter
    - jupyter-kernel
    - jupyter-kernelspec
    - jupyter-migrate
    - jupyter-run
    - jupyter-troubleshoot
    - pygmentize
    - man1/ipython.1
   package jupyter 1.1.1, installed using Python 3.12.3
    - httpx
    - jlpm
    - jsonpointer
    - jsonschema
    - jupyter-console
    - jupyter-dejavu
    - jupyter-events
    - jupyter-execute
    - jupyter-lab
    - jupyter-labextension
    - jupyter-labhub
    - jupyter-nbconvert
    - jupyter-notebook
    - jupyter-server
    - jupyter-trust
    - normalizer
    - pybabel
    - pyjson5
    - send2trash
    - wsdump
    - debugpy (symlink missing or pointing to unexpected location)
    - ipython (symlink missing or pointing to unexpected location)
    - ipython3 (symlink missing or pointing to unexpected location)
    - jupyter (symlink missing or pointing to unexpected location)
    - jupyter-kernel (symlink missing or pointing to unexpected location)
    - jupyter-kernelspec (symlink missing or pointing to unexpected location)
    - jupyter-migrate (symlink missing or pointing to unexpected location)
    - jupyter-run (symlink missing or pointing to unexpected location)
    - jupyter-troubleshoot (symlink missing or pointing to unexpected location)
    - pygmentize (symlink missing or pointing to unexpected location)
    - man1/ipython.1 (symlink missing or pointing to unexpected location)
   package jupyter-core 5.7.2, installed using Python 3.12.3
    - jupyter (symlink missing or pointing to unexpected location)
    - jupyter-migrate (symlink missing or pointing to unexpected location)
    - jupyter-troubleshoot (symlink missing or pointing to unexpected location)
   package jupyterlab 4.2.5, installed using Python 3.12.3
    - jlpm (symlink missing or pointing to unexpected location)
    - jupyter-lab (symlink missing or pointing to unexpected location)
    - jupyter-labextension (symlink missing or pointing to unexpected location)
    - jupyter-labhub (symlink missing or pointing to unexpected location)
   package matplotlib 3.9.2, installed using Python 3.12.3
    - fonttools
    - pyftmerge
    - pyftsubset
    - ttx
    - f2py (symlink missing or pointing to unexpected location)
    - numpy-config (symlink missing or pointing to unexpected location)
    - man1/ttx.1
   package notebook 7.2.2, installed using Python 3.12.3
    - debugpy (symlink missing or pointing to unexpected location)
    - httpx (symlink missing or pointing to unexpected location)
    - ipython (symlink missing or pointing to unexpected location)
    - ipython3 (symlink missing or pointing to unexpected location)
    - jlpm (symlink missing or pointing to unexpected location)
    - jsonpointer (symlink missing or pointing to unexpected location)
    - jsonschema (symlink missing or pointing to unexpected location)
    - jupyter (symlink missing or pointing to unexpected location)
    - jupyter-dejavu (symlink missing or pointing to unexpected location)
    - jupyter-events (symlink missing or pointing to unexpected location)
    - jupyter-execute (symlink missing or pointing to unexpected location)
    - jupyter-kernel (symlink missing or pointing to unexpected location)
    - jupyter-kernelspec (symlink missing or pointing to unexpected location)
    - jupyter-lab (symlink missing or pointing to unexpected location)
    - jupyter-labextension (symlink missing or pointing to unexpected location)
    - jupyter-labhub (symlink missing or pointing to unexpected location)
    - jupyter-migrate (symlink missing or pointing to unexpected location)
    - jupyter-nbconvert (symlink missing or pointing to unexpected location)
    - jupyter-notebook (symlink missing or pointing to unexpected location)
    - jupyter-run (symlink missing or pointing to unexpected location)
    - jupyter-server (symlink missing or pointing to unexpected location)
    - jupyter-troubleshoot (symlink missing or pointing to unexpected location)
    - jupyter-trust (symlink missing or pointing to unexpected location)
    - normalizer (symlink missing or pointing to unexpected location)
    - pybabel (symlink missing or pointing to unexpected location)
    - pygmentize (symlink missing or pointing to unexpected location)
    - pyjson5 (symlink missing or pointing to unexpected location)
    - send2trash (symlink missing or pointing to unexpected location)
    - wsdump (symlink missing or pointing to unexpected location)
    - man1/ipython.1 (symlink missing or pointing to unexpected location)
   package numpy 2.1.0, installed using Python 3.12.3
    - f2py
    - numpy-config

Now, running jupyter notebook is showing a blank page in the browser. And while trying to run the ipynb notebook on VS code, I am getting Running cells with 'Python 3.12.3' requires the ipykernel package.

raf
  • 599
  • Please specify the error you got with pip. Since Ubuntu 23.04 pip requires to install packages inside a venv, otherwise you receive an error message. – noisefloor Sep 01 '24 at 17:50

3 Answers3

8

You can install ipython with apt using sudo apt install python3-ipython jupyter. I have verified that it works in Ubuntu 24.04. Remove the pipx package.

Some users have reported issues with jupyter notebook and snap firefox. You can install the APT version of Firefox for better compatibility. See How to install Firefox as a traditional deb package (without snap) in Ubuntu 22.04 or later versions?

  • It worked for jupyter, and the browser/VS code issue is solved with it. But seems like this method doesn't work for every python package. For example, sudo apt install python3-pytearcat is not working or installing https://pypi.org/project/pytearcat/. – raf Sep 01 '24 at 17:21
  • For such packages, you have to use pip. Use pip install --user pytearcat --break-system-packages – Archisman Panigrahi Sep 01 '24 at 20:32
  • The original question was about jupyter (and not every python package). If that works for you, please click on the checkmark on the left side of the answer to accept it. If you have another question about arbitrary python packages, please ask a new question – Archisman Panigrahi Sep 01 '24 at 22:10
4

My notebook package also got broken, but

pipx reinstall notebook

fixed it.

On a side note, your pipx list shows too many pipx packages. I think you misunderstand what pipx is. pipx installs packages into its own virtual environment and then "exports" its scripts. Different packages are independent, so your package notebook has no access to the package numpy. To install python packages into pipx packages, you need to use pipx inject. So to install numpy and matplotlib into your notebook installation, you would run

pipx inject notebook numpy matplotlib
Dodezv
  • 141
  • Thank you. Yes, I misunderstood the use of pipx. – raf Sep 02 '24 at 14:30
  • I think of pipx as way of installing stand-along python programs, not libraries. E.g. is is it a cli program -- then go pipx. – laur Nov 05 '24 at 14:22
2

Ubuntu can have a python without pip by following this steps.

  1. Install a virtual environment library.

    sudo apt install python3-venv
    
  2. Create an environment (Here I will use my_env).

    python3 -m venv my_env
    
  3. Activate this env.

    source my_env\bin\ activate
    

    Note: You should see the name of my_env in a parentheses first of line.In the below screenshot my environment name is torch.

    Screenshot

  4. Update pip.

    pip install -m pip --upgrade
    
karel
  • 122,695
  • 134
  • 305
  • 337
nima pm
  • 21