@@ -280,35 +280,82 @@ 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+ ### Preferences
284+
285+ You can configure PythonCall with the preferences listed below. These can be set either as
286+ [ Julia preferences] ( https://github.com/JuliaPackaging/Preferences.jl ) or as environment
287+ variables.
288+
289+ | Preference | Environment Variable | Description |
290+ | ---------- | -------------------- | ----------- |
291+ | ` exe ` | ` JULIA_PYTHONCALL_EXE ` | Path to the Python executable, or special values (see below). |
292+ | ` lib ` | ` JULIA_PYTHONCALL_LIB ` | Path to the Python library (usually inferred automatically). |
293+ | ` pickle ` | ` JULIA_PYTHONCALL_PICKLE ` | Pickle module to use for serialization (` pickle ` or ` dill ` ). |
294+
295+ The easiest way to set these preferences is with the
296+ [ ` PreferenceTools ` ] ( https://github.com/cjdoris/PreferenceTools.jl )
297+ package. For example:
298+ ```
299+ julia> using PreferenceTools
300+ julia> # now press ] to enter the Pkg REPL
301+ pkg> preference add PythonCall exe=/path/to/python
302+ ```
303+
304+ For CondaPkg preferences (such as ` backend ` , ` exe ` , ` env ` ), see the
305+ [ CondaPkg documentation] ( https://github.com/JuliaPy/CondaPkg.jl#preferences ) .
306+
307+ ### Special ` exe ` values
308+
309+ The ` exe ` preference (or ` JULIA_PYTHONCALL_EXE ` environment variable) supports the following
310+ special values:
311+ - Empty string or ` @CondaPkg ` : Use Python from CondaPkg (the default).
312+ - ` @PyCall ` : Use the same Python as PyCall. [ See here] (@ref faq-pycall).
313+ - ` @venv ` : Use Python from a ` .venv ` virtual environment in the current active project.
314+
315+ Otherwise, the value is interpreted as:
316+ - An absolute path to a Python executable.
317+ - A relative path (containing ` / ` or ` \ ` ) resolved relative to the current active project.
318+ - A command name to search for in ` PATH ` .
319+
320+ ### If you already have Python and required Python packages installed
284321
285322``` julia
286323ENV [" JULIA_CONDAPKG_BACKEND" ] = " Null"
287324ENV [" JULIA_PYTHONCALL_EXE" ] = " /path/to/python" # optional
288- ENV [" JULIA_PYTHONCALL_EXE" ] = " @PyCall" # optional
289- ENV [" JULIA_PYTHONCALL_EXE" ] = " @venv" # optional
325+ ```
326+
327+ Or using preferences:
328+ ```
329+ pkg> preference add CondaPkg backend=Null
330+ pkg> preference add PythonCall exe=/path/to/python # optional
290331```
291332
292333By setting the CondaPkg backend to Null, it will never install any Conda packages. In this
293334case, PythonCall will use whichever Python is currently installed and in your ` PATH ` . You
294335must have already installed any Python packages that you need.
295336
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.
337+ If ` python ` is not in your ` PATH ` , you will also need to set ` exe ` (or ` JULIA_PYTHONCALL_EXE ` )
338+ to its path. Relative paths are resolved relative to the current active project.
298339
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).
340+ If you also use PyCall, you can set ` exe =@PyCall` to use the same Python interpreter.
341+ [ See here] (@ref faq-pycall).
301342
302343If you have a Python virtual environment at ` .venv ` in your current active project, you
303- can set ` JULIA_PYTHONCALL_EXE =@venv` to use it.
344+ can set ` exe =@venv` to use it.
304345
305- #### If you already have a Conda environment
346+ ### If you already have a Conda environment
306347
307348``` julia
308349ENV [" JULIA_CONDAPKG_BACKEND" ] = " Current"
309350ENV [" JULIA_CONDAPKG_EXE" ] = " /path/to/conda" # optional
310351```
311352
353+ Or using preferences:
354+ ```
355+ pkg> preference add CondaPkg backend=Current
356+ pkg> preference add CondaPkg exe=/path/to/conda # optional
357+ ```
358+
312359The Current backend to CondaPkg will use the currently activated Conda environment instead
313360of creating a new one.
314361
@@ -317,23 +364,29 @@ If you already have your dependencies installed and do not want the environment
317364modified, then see the previous section.
318365
319366If ` conda ` , ` mamba ` or ` micromamba ` is not in your ` PATH ` you will also need to set
320- ` JULIA_CONDAPKG_EXE ` to its path.
367+ ` JULIA_CONDAPKG_EXE ` (or the CondaPkg ` exe ` preference) to its path.
321368
322- #### If you already have Conda, Mamba or MicroMamba
369+ ### If you already have Conda, Mamba or MicroMamba
323370
324371``` julia
325372ENV [" JULIA_CONDAPKG_BACKEND" ] = " System"
326373ENV [" JULIA_CONDAPKG_EXE" ] = " /path/to/conda" # optional
327374```
328375
376+ Or using preferences:
377+ ```
378+ pkg> preference add CondaPkg backend=System
379+ pkg> preference add CondaPkg exe=/path/to/conda # optional
380+ ```
381+
329382The System backend to CondaPkg will use your preinstalled Conda implementation instead of
330383downloading one.
331384
332385Note that this will still create a new Conda environment and install any required packages
333386into it. If you want to use a pre-existing Conda environment, see the previous section.
334387
335388If ` conda ` , ` mamba ` or ` micromamba ` is not in your ` PATH ` you will also need to set
336- ` JULIA_CONDAPKG_EXE ` to its path.
389+ ` JULIA_CONDAPKG_EXE ` (or the CondaPkg ` exe ` preference) to its path.
337390
338391## [ Installing Python packages] (@id python-deps)
339392
0 commit comments