@@ -280,35 +280,80 @@ By default, PythonCall uses [CondaPkg.jl](https://github.com/JuliaPy/CondaPkg.jl
280280its dependencies. This will install Conda and use it to create a Conda environment specific
281281to your current Julia project containing Python and any required Python packages.
282282
283- #### If you already have Python and required Python packages installed
283+ You can configure PythonCall with the preferences listed below. These can be set either as
284+ [ Julia preferences] ( https://github.com/JuliaPackaging/Preferences.jl ) or as environment
285+ variables.
286+
287+ | Preference | Environment Variable | Description |
288+ | ---------- | -------------------- | ----------- |
289+ | ` exe ` | ` JULIA_PYTHONCALL_EXE ` | Path to the Python executable, or special values (see below). |
290+ | ` lib ` | ` JULIA_PYTHONCALL_LIB ` | Path to the Python library (usually inferred automatically). |
291+ | ` pickle ` | ` JULIA_PYTHONCALL_PICKLE ` | Pickle module to use for serialization (` pickle ` or ` dill ` ). |
292+
293+ The easiest way to set these preferences is with the
294+ [ ` PreferenceTools ` ] ( https://github.com/cjdoris/PreferenceTools.jl )
295+ package. For example:
296+ ```
297+ julia> using PreferenceTools
298+ julia> # now press ] to enter the Pkg REPL
299+ pkg> preference add PythonCall exe=/path/to/python
300+ ```
301+
302+ For CondaPkg preferences (such as ` backend ` , ` exe ` , ` env ` ), see the
303+ [ CondaPkg documentation] ( https://github.com/JuliaPy/CondaPkg.jl#preferences ) .
304+
305+ ### Special ` exe ` values
306+
307+ The ` exe ` preference (or ` JULIA_PYTHONCALL_EXE ` environment variable) supports the following
308+ special values:
309+ - ` @CondaPkg ` : Use Python from CondaPkg (the default).
310+ - ` @PyCall ` : Use the same Python as PyCall. [ See here] (@ref faq-pycall).
311+ - ` @venv ` : Use Python from a ` .venv ` virtual environment in the current active project.
312+
313+ Otherwise, the value is interpreted as:
314+ - An absolute path to a Python executable.
315+ - A relative path (containing ` / ` or ` \ ` ) resolved relative to the current active project.
316+ - A command name to search for in ` PATH ` .
317+
318+ ### If you already have Python and required Python packages installed
284319
285320``` julia
286321ENV [" JULIA_CONDAPKG_BACKEND" ] = " Null"
287322ENV [" JULIA_PYTHONCALL_EXE" ] = " /path/to/python" # optional
288- ENV [" JULIA_PYTHONCALL_EXE" ] = " @PyCall" # optional
289- ENV [" JULIA_PYTHONCALL_EXE" ] = " @venv" # optional
323+ ```
324+
325+ Or using preferences:
326+ ```
327+ pkg> preference add CondaPkg backend=Null
328+ pkg> preference add PythonCall exe=/path/to/python # optional
290329```
291330
292331By setting the CondaPkg backend to Null, it will never install any Conda packages. In this
293332case, PythonCall will use whichever Python is currently installed and in your ` PATH ` . You
294333must have already installed any Python packages that you need.
295334
296- If ` python ` is not in your ` PATH ` , you will also need to set ` JULIA_PYTHONCALL_EXE ` to its
297- path. Relative paths are resolved relative to the current active project.
335+ If ` python ` is not in your ` PATH ` , you will also need to set ` exe ` (or ` JULIA_PYTHONCALL_EXE ` )
336+ to its path. Relative paths are resolved relative to the current active project.
298337
299- If you also use PyCall, you can set ` JULIA_PYTHONCALL_EXE =@PyCall` to use the same Python
300- interpreter. [ See here] (@ref faq-pycall).
338+ If you also use PyCall, you can set ` exe =@PyCall` to use the same Python interpreter.
339+ [ See here] (@ref faq-pycall).
301340
302341If you have a Python virtual environment at ` .venv ` in your current active project, you
303- can set ` JULIA_PYTHONCALL_EXE =@venv` to use it.
342+ can set ` exe =@venv` to use it.
304343
305- #### If you already have a Conda environment
344+ ### If you already have a Conda environment
306345
307346``` julia
308347ENV [" JULIA_CONDAPKG_BACKEND" ] = " Current"
309348ENV [" JULIA_CONDAPKG_EXE" ] = " /path/to/conda" # optional
310349```
311350
351+ Or using preferences:
352+ ```
353+ pkg> preference add CondaPkg backend=Current
354+ pkg> preference add CondaPkg exe=/path/to/conda # optional
355+ ```
356+
312357The Current backend to CondaPkg will use the currently activated Conda environment instead
313358of creating a new one.
314359
@@ -317,23 +362,29 @@ If you already have your dependencies installed and do not want the environment
317362modified, then see the previous section.
318363
319364If ` conda ` , ` mamba ` or ` micromamba ` is not in your ` PATH ` you will also need to set
320- ` JULIA_CONDAPKG_EXE ` to its path.
365+ ` JULIA_CONDAPKG_EXE ` (or the CondaPkg ` exe ` preference) to its path.
321366
322- #### If you already have Conda, Mamba or MicroMamba
367+ ### If you already have Conda, Mamba, MicroMamba or Pixi
323368
324369``` julia
325- ENV [" JULIA_CONDAPKG_BACKEND" ] = " System"
370+ ENV [" JULIA_CONDAPKG_BACKEND" ] = " System" # or "SystemPixi" for Pixi
326371ENV [" JULIA_CONDAPKG_EXE" ] = " /path/to/conda" # optional
327372```
328373
329- The System backend to CondaPkg will use your preinstalled Conda implementation instead of
330- downloading one.
374+ Or using preferences:
375+ ```
376+ pkg> preference add CondaPkg backend=System
377+ pkg> preference add CondaPkg exe=/path/to/conda # optional
378+ ```
379+
380+ The System (or SystemPixi) backend to CondaPkg will use your preinstalled Conda (or
381+ Pixi) implementation instead of downloading one.
331382
332383Note that this will still create a new Conda environment and install any required packages
333384into it. If you want to use a pre-existing Conda environment, see the previous section.
334385
335- If ` conda ` , ` mamba ` or ` micromamba ` is not in your ` PATH ` you will also need to set
336- ` JULIA_CONDAPKG_EXE ` to its path.
386+ If ` conda ` , ` mamba ` , ` micromamba ` or ` pixi ` is not in your ` PATH ` you will also need to
387+ set ` JULIA_CONDAPKG_EXE ` (or the CondaPkg ` exe ` preference) to its path.
337388
338389## [ Installing Python packages] (@id python-deps)
339390
0 commit comments