From 8d0ce84ff4373f999d61f7efd285b0abbb7a4c7a Mon Sep 17 00:00:00 2001 From: icweaver Date: Mon, 9 Jun 2025 22:17:38 -0700 Subject: [PATCH 1/2] added some docs for code loading edge case --- docs/src/pythoncall.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/src/pythoncall.md b/docs/src/pythoncall.md index 8b8f19a1..23c98967 100644 --- a/docs/src/pythoncall.md +++ b/docs/src/pythoncall.md @@ -308,6 +308,19 @@ To add dependencies to a Julia package, just ensure the package project is activ See the [CondaPkg.jl](https://github.com/JuliaPy/CondaPkg.jl) documentation. +!!! note + If running from a script, make sure that [CondaPkg.jl](https://github.com/JuliaPy/CondaPkg.jl) is used before [PythonCall.jl](https://github.com/JuliaPy/PythonCall.jl) to ensure proper loading of Python packages in your path. E.g., + + ```julia + using CondaPkg + + CondaPkg.add("numpy") + + using PythonCall + + np = pyimport("numpy") + ``` + ## Writing packages which depend on PythonCall ### Example From bac4a395adbd5bc8b65a075502ad59022e8b75fc Mon Sep 17 00:00:00 2001 From: icweaver Date: Mon, 9 Jun 2025 22:33:43 -0700 Subject: [PATCH 2/2] moved to faq --- docs/src/faq.md | 14 ++++++++++++++ docs/src/pythoncall.md | 13 ------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/src/faq.md b/docs/src/faq.md index eefa12df..d78bf486 100644 --- a/docs/src/faq.md +++ b/docs/src/faq.md @@ -89,3 +89,17 @@ Related issues: [#255](https://github.com/JuliaPy/PythonCall.jl/issues/255) Yes, it may be possible. A good example of that is having Julia running inside the Python that is running inside Blender, as presented in [this Discourse post](https://discourse.julialang.org/t/running-julia-inside-blender-through-vscode-using-pythoncall-juliacall/96838/6). From the point that one has JuliaCall running inside Python, if it has access to the terminal, one can even launch a Julia REPL there, and if needed connect with VSCode Julia extension to it. The full Python script to install, launch JuliaCall, and launch a Julia REPL in Blender is [here](https://gist.github.com/cdsousa/d820d27174238c0d48e5252355584172). + +## Using PythonCall.jl and CondaPkg.jl in a script + +If running from a script, make sure that [CondaPkg.jl](https://github.com/JuliaPy/CondaPkg.jl) is used before [PythonCall.jl](https://github.com/JuliaPy/PythonCall.jl) to ensure proper loading of Python packages in your path. E.g., + +```julia +using CondaPkg + +CondaPkg.add("numpy") + +using PythonCall + +np = pyimport("numpy") +``` diff --git a/docs/src/pythoncall.md b/docs/src/pythoncall.md index 23c98967..8b8f19a1 100644 --- a/docs/src/pythoncall.md +++ b/docs/src/pythoncall.md @@ -308,19 +308,6 @@ To add dependencies to a Julia package, just ensure the package project is activ See the [CondaPkg.jl](https://github.com/JuliaPy/CondaPkg.jl) documentation. -!!! note - If running from a script, make sure that [CondaPkg.jl](https://github.com/JuliaPy/CondaPkg.jl) is used before [PythonCall.jl](https://github.com/JuliaPy/PythonCall.jl) to ensure proper loading of Python packages in your path. E.g., - - ```julia - using CondaPkg - - CondaPkg.add("numpy") - - using PythonCall - - np = pyimport("numpy") - ``` - ## Writing packages which depend on PythonCall ### Example