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

venv installed packages stopped working with jupyter lab #49402

Closed
Eloitor opened this issue Mar 20, 2024 · 5 comments
Closed

venv installed packages stopped working with jupyter lab #49402

Eloitor opened this issue Mar 20, 2024 · 5 comments

Comments

@Eloitor
Copy link
Contributor

Eloitor commented Mar 20, 2024

Is this a new report?

Yes

System Info

Void 6.6.22_1 x86_64 GenuineIntel uptodate hold rFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Package(s) Affected

python3-3.12.2_2, jupyterlab-4.0.12_1

Does a report exist for this bug with the project's home (upstream) and/or another distro?

marimo-team/marimo#968

Expected behaviour

I install a package in a python venv following the instuctions from
and after activating it I can use it in jupyter lab. #47135 (comment)

This worked for me before but no longer works??? I don't know what happened...

Actual behaviour

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 1
----> 1 from cool_lib import a

ModuleNotFoundError: No module named 'cool_lib'

Steps to reproduce

  1. Install jupyterlab
  2. Run:
python -m venv --system-site-packages ~/venv
git clone https://github.com/gdamjan/hello-world-python-package.git
cd hello-world-python-package
~/venv/bin/pip install -e .
cd ..
. ~/venv/bin/activate
jupyter lab
  1. In jupyter lab
from cool_lib import a
@Eloitor Eloitor added bug Something isn't working needs-testing Testing a PR or reproducing an issue needed labels Mar 20, 2024
@classabbyamp
Copy link
Member

~/venv/bin/python -m ipykernel install --name my_cool_venv and it will show up as a kernel

@Eloitor
Copy link
Contributor Author

Eloitor commented Mar 20, 2024

Thanks!! This works with jupyter lab very cool trick to be able to use kernels with custom environments!

However this trick does not work with marimo as it does not use ipython. #48818

This worked before, and I'm very surprised that it doesn't work now....

@Eloitor
Copy link
Contributor Author

Eloitor commented Mar 20, 2024

mmm... runing python -m marimo edit test.py works. But before I only needed marimo edit test.py

@ahesford ahesford removed bug Something isn't working needs-testing Testing a PR or reproducing an issue needed labels Mar 21, 2024
@ahesford
Copy link
Member

This is expected behavior. When packages are built with xbps-src, the shebang in Python scripts is deliberately overwritten to use /usr/bin/python3 instead of whatever Python interpreter might be in your path. Hence, running jupyter will ignore the virtual environment. We do this to ensure that Void-packaged Python scripts behave in a predictable manner.

If you want to override the shebang in Void-packaged scripts, you'll have to explicitly run the interpreter. You can write a wrapper or define an alias to make this happen.

@ahesford ahesford closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2024
@Eloitor
Copy link
Contributor Author

Eloitor commented Mar 21, 2024

This makes sense, but it is very strange too, because I was using this until yesterday when it stopped working...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants