JuliaPy / JuliaPy/PythonCall.jl

Weird interaction with Jupyter notebooks resulting in "forgetting" the Julia dependencies

Đang mở
#497 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Julia
Star
1.1k
Fork
86
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
3

Mô tả

**Affects:** JuliaCall

**Describe the bug**
Just flagging this in case others have seen it. I will:

1. Install my environment from the command line, using `pip`.
2. Use, e.g., `python -c 'import pysr'` to set up the Julia environment.
3. Then, I will open a Jupyter notebook, set the kernel to the one in my virtualenv, and import my juliacall-enabled package (in this case, PySR).

Sometimes I do this, and it seems to... "forget" what Julia packages are in my environment. In other words, when I do

```python
import pysr
```

It will start re-installing the environment, with **only** PythonCall.jl. It seems like the first time it hits a `from juliacall import Main`, it just "resets" the Julia project and forgets the `juliapkg.json` previously used.

I wonder if this might be because the ipykernel itself is installed via a different python virtualenv? However it still seems to import the Python packages correctly; it just ends up uninstalling the Julia dependencies...

*Reproducing*. You can try to reproduce this as follows (not positive what seems to cause this; it might work or might not work for you):

1. Create a virtualenv at `/path/to/my/.venv` and install pysr, ipython, ipykernel, and jupyter with pip.
2. Start ipython, and import pysr. This will trigger the juliapkg set up of the Julia project with the correct dependencies.
3. Now, close ipython, and open Jupyter. Set the Jupyter kernel to be `/path/to/my/.venv`. Now, in Jupyter, import pysr.

You might see that it will start re-installing the Julia project, but this time, only with PythonCall.jl, and no other dependencies. It will fail halfway through

Any idea @cjdoris? How are `juliapkg.json` used at import time to generate the right installation commands? Maybe I can provide more debugging info in some way.

Maybe I just have weird ipykernel settings and nobody can reproduce this?? Or perhaps the juliapkg.json isn't getting packaged correctly in the wheel?

**Your system**
Please provide detailed information about your system:
- The operating system: macOS
- The version of:
- Julia: 1.10.3
- Python: 3.12.2
- PythonCall: 0.9.20 (also see this on 0.9.19)

**Additional context**

IPython always seems safe. Never had an issue. It's exclusively Jupyter notebooks (both in VSCode, and in regular Jupyter notebooks in the browser) where the juliapkg "forgetfulness" happens.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Start by reproducing the virtualenv, IPython, and Jupyter kernel sequence described, comparing the `import pysr` entry point in IPython and Jupyter. Inspect how `juliapkg.json` is used during import and verify that the Jupyter case preserves the Julia dependencies instead of reinstalling only PythonCall.jl.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
julia, jupyter-notebook, python
Lĩnh vực
developer-experience, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.