Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import numpy package after Ubuntu upgrade #16267

Closed
UriBarkan opened this issue Apr 30, 2024 · 8 comments
Closed

Unable to import numpy package after Ubuntu upgrade #16267

UriBarkan opened this issue Apr 30, 2024 · 8 comments
Labels
bug status:Needs Info status:Needs Triage Applied to new issues that need triage

Comments

@UriBarkan
Copy link

Hi,

Description:
Last week I upgraded to Ubuntu 24.04. After the upgrade, when trying to import numpy (for example) in JupyterLab, I get the following message:
ModuleNotFoundError: No module named 'numpy'

Screenshot Jupyterlab debug

When I run Python from terminal or when I try importing the same package on Jupyter notebook, even on the same browser, import is successful. Also, if I open terminal within jupyter-lab (from the launcher) import is also successful. So import fails only when importing from notebooks (tried from different ones).

Disabled all plugins. Also, tried to reinstall jupyter-lab (“pipx reinstall jupyterlab”), to no avail.

Reproduce:

  1. Install Jupyterlab and numpy on Ubuntu 23.10 machine.
  2. Upgrade to Ubuntu 24.04.
  3. Launch Jupyterlab from terminal.
  4. type "import numpy as np" in jupyterlab and run the cell.

Expected behavior:
numpy to load successfully.

Context:
OS: Linux Ubuntu 24.04.
Brwoser: Chromium Version 124.0.6367.60 (Official Build) snap (64-bit)
Also tested on Firefox 125.0.3 (64-bit) and got the same error
Jupyterlab 4.1.8
Jupyter-notebook 6.4.12 (the error is not reproducible in Jupyter-notebook, only in Jupyterlab)
Python 3.12.3

Troubleshoot output:
bash: /x/y/.local/bin/jupyter-troubleshoot: cannot execute: required file not found
For 'jupyter-lab --debug' please see attached text file:
jupyter lab debug.txt
For browser output see the screenshot:
Screenshot Jupyterlab debug browser

Thanks!

@UriBarkan UriBarkan added the bug label Apr 30, 2024
@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Apr 30, 2024
Copy link

welcome bot commented Apr 30, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@JasonWeill
Copy link
Contributor

@UriBarkan Thanks for opening this issue! I saw that you were unable to reproduce this using Python on the command line. If you run ipython on the command line, does import fail as well? If so, it's more likely an issue with your kernel than it is in JupyterLab.

@UriBarkan
Copy link
Author

Hi @JasonWeill,

Thanks for your reply! I can import numpy also in ipython (e.g. in Spyder IDE w/ ipython console). Up to now I've encountered this problem only in Jupyterlab.

@JasonWeill
Copy link
Contributor

If you run %pip install numpy from within your notebook, what output do you see? After you run this command, can you successfully import numpy?

@UriBarkan
Copy link
Author

UriBarkan commented May 14, 2024

From within jupyterlab:

!pipx install numpy
⡿ installing numpy environment⚠️  Note: f2py was already on your PATH at /usr/bin/f2py
  installed package numpy 1.26.4, installed using Python 3.12.3
  These apps are now globally available
    - f2py
done! ✨ 🌟 ✨

import numpy as np
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[4], line 1
----> 1 import numpy as np

ModuleNotFoundError: No module named 'numpy'

Then if I try to run again:

!pipx install numpy
'numpy' already seems to be installed. Not modifying existing installation in
'/home/uri/.local/pipx/venvs/numpy'. Pass '--force' to force installation.

But I get the same error when trying to import numpy.

@JasonWeill
Copy link
Contributor

Thanks for your reply! After installing the module, can you try restarting the kernel? After that kernel is restarted, does the import numpy as np line work as intended?

@UriBarkan
Copy link
Author

Unfortunately no, nympy cannot be imported also after kernel restart.

@UriBarkan
Copy link
Author

UriBarkan commented May 19, 2024

I was able to overcome the issue by redefining the virtual environment. I guess in the upgrade process of Ubuntu something broke.

A fix for future users:

  1. Define a new virtual environment: python3 -m venv /my/venv/directory
  2. Activate: source /my/venv/directory/bin/activate
  3. Install: pip install jupyterlab
  4. Install other packages required: pip install numpy/scipy/etc.

I took the liberty of closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status:Needs Info status:Needs Triage Applied to new issues that need triage
Projects
None yet
Development

No branches or pull requests

2 participants