Skip to content

Commit

Permalink
Fix python dependency issues with Python 3.12 and add to docs (#319)
Browse files Browse the repository at this point in the history
* update python deps

* docs to solve installation issues

* windows test bugfix

* rm matplotlib
  • Loading branch information
odunbar authored Sep 6, 2024
1 parent d83cb5a commit db593be
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ steps:
command:
- "echo $$JULIA_DEPOT_PATH"
- "julia --project -e 'using Pkg; Pkg.instantiate(;verbose=true)'"
- "julia --project -e 'using Conda; Conda.add(\"scipy=1.8.1\", channel=\"conda-forge\")'"
- "julia --project -e 'using Conda; Conda.add(\"scikit-learn=1.1.1\")'"
- "julia --project -e 'using Conda; Conda.add(\"matplotlib=3.7.1\")'"
- "julia --project -e 'using Conda; Conda.add(\"scipy=1.14.1\", channel=\"conda-forge\")'"
- "julia --project -e 'using Conda; Conda.add(\"scikit-learn=1.5.1\")'"
env:
PYTHON: ""

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
PYTHON: ""
run: |
julia --color=yes --project -e 'using Pkg; Pkg.instantiate()'
julia --project -e 'using Conda; Conda.add("scipy=1.8.1")'
julia --color=yes --project -e 'using Conda; Conda.add("scikit-learn=1.1.1")'
julia --project -e 'using Conda; Conda.add("scipy=1.14.1")'
julia --color=yes --project -e 'using Conda; Conda.add("scikit-learn=1.5.1")'
julia --color=yes --project=docs/ -e 'using Pkg; Pkg.instantiate()'
julia --color=yes --project=docs/ -e 'using Pkg; Pkg.precompile()'
- name: Build and deploy
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
env:
PYTHON: ""
run: |
julia --project -e 'using Conda; Conda.add("scipy=1.8.1")'
julia --project -e 'using Conda; Conda.add("scikit-learn=1.1.1")'
julia --project -e 'using Conda; Conda.add("scipy=1.14.1")'
julia --project -e 'using Conda; Conda.add("scikit-learn=1.5.1")'
- name: Run Unit Tests
env:
Expand Down Expand Up @@ -92,8 +92,8 @@ jobs:
env:
PYTHON: ""
run: |
julia --project -e 'using Conda; Conda.add("scipy=1.8.1")'
julia --project -e 'using Conda; Conda.add("scikit-learn=1.1.1")'
julia --project -e 'using Conda; Conda.add("scipy=1.14.1")'
julia --project -e 'using Conda; Conda.add("scikit-learn=1.5.1")'
- name: Run Unit Tests
env:
Expand Down Expand Up @@ -132,8 +132,8 @@ jobs:
env:
PYTHON: ""
run: |
julia --project -e 'using Conda; Conda.add("scipy=1.8.1")'
julia --project -e 'using Conda; Conda.add(\"scikit-learn=1.1.1\")'
julia --project -e 'using Conda; Conda.add("scipy=1.14.1")'
julia --project -e 'using Conda; Conda.add("scikit-learn=1.5.1")'
- name: Run Unit Tests
env:
Expand Down
26 changes: 22 additions & 4 deletions docs/src/installation_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
### Installing CalibrateEmulateSample.jl

Currently CalibrateEmulateSample (CES) depends on some external python dependencies
including `scipy` (version `1.8.1` works) and `scikit-learn` (version `1.1.1` works) that are wrapped by ScikitLearn.jl.

!!! info "Latest python package versions!"
We have verified that the configurations work:
For Python `3.11 - 3.12`: `scipy` = `1.14.1`, `scikit-learn` = `1.5.1`.
For Python `3.8 - 3.11`: `scipy` = `1.8.1`, `scikit-learn` = `1.1.1`.
Please create an issue if you have had success with more up-to-date versions, and we can update this page!

If you have dependencies installed already, then the code can be used by simply entering

```
Expand Down Expand Up @@ -32,10 +36,24 @@ Then install the dependencies by having the project use its own [Conda](https://
This call should build Conda and Pycall. The `scikit-learn` package (along with `scipy`) then has to be installed if using a Julia project-specific Conda environment:

```
> PYTHON="" julia --project -e 'using Conda; Conda.add("scipy=1.8.1", channel="conda-forge")'
> PYTHON="" julia --project -e 'using Conda; Conda.add("scikit-learn=1.1.1")'
> PYTHON="" julia --project -e 'using Conda; Conda.add("scipy=1.14.1", channel="conda-forge")'
> PYTHON="" julia --project -e 'using Conda; Conda.add("scikit-learn=1.5.1")'
```
!!! info "Pycall can't find the packages!?"
Sometimes `Conda.jl` builds the python packages, in julia-based python repo but Pycall resorts to a different python path. this throws an error like:
```
ERROR: InitError: PyError (PyImport_ImportModule

The Python package sklearn.gaussian_process.kernels could not be imported by pyimport.
```
In this case, simply call `julia --project` followed by
```julia
julia> ENV["PYTHON"]=""
julia> Pkg.build("PyCall")
julia> exit()
```
to reset unify the paths.

See the [PyCall.jl documentation](https://github.com/JuliaPy/PyCall.jl#specifying-the-python-version)
for more information about how to configure the local Julia / Conda / Python environment.
Expand Down

0 comments on commit db593be

Please sign in to comment.