JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.46k stars 187 forks source link

Deprecation warning suggesting to use jl.eval() when one is actually doing it #964

Closed sylvaticus closed 2 years ago

sylvaticus commented 2 years ago

Hello, I don't understand this warning as it seems to suggest to do what I am actually doing:

$ python
Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import julia
>>> julia.install()
[ Info: Julia version info
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
      Ubuntu 20.04.3 LTS
  uname: Linux 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64
  CPU: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz: 
              speed         user         nice          sys         idle          irq
       #1  2972 MHz      33653 s        184 s      12264 s     897983 s          0 s
       #2  2961 MHz      34941 s        236 s      12212 s     628489 s          0 s
       #3  2934 MHz      33904 s        286 s      12655 s     643670 s          0 s
       #4  2933 MHz      34860 s        326 s      11468 s     645736 s          0 s
       #5  2956 MHz      33376 s        216 s      10912 s     646829 s          0 s
       #6  2926 MHz      32942 s        166 s      11702 s     646353 s          0 s
       #7  2969 MHz      33645 s        286 s      12235 s     644322 s          0 s
       #8  2966 MHz      33140 s        170 s      11541 s     646403 s          0 s

  Memory: 15.49658203125 GB (498.50390625 MB free)
  Uptime: 102085.33 sec
  Load Avg:  0.47  0.73  0.71
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
  PYENV_HOOK_PATH = /home/user/.pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks:/home/user/.pyenv/plugins/pyenv-virtualenv/etc/pyenv.d:/home/user/.pyenv/plugins/pyenv-which-ext/etc/pyenv.d
  MANDATORY_PATH = /usr/share/gconf/ubuntu.mandatory.path
  WINDOWPATH = 2
  HOME = /home/user
  TERM = xterm-256color
  DEFAULTS_PATH = /usr/share/gconf/ubuntu.default.path
  PATH = /home/user/.pyenv/libexec:/home/user/.pyenv/plugins/python-build/bin:/home/user/.pyenv/plugins/pyenv-virtualenv/bin:/home/user/.pyenv/plugins/pyenv-update/bin:/home/user/.pyenv/plugins/pyenv-installer/bin:/home/user/.pyenv/plugins/pyenv-doctor/bin:/home/user/.pyenv/plugins/pyenv-virtualenv/shims:/home/user/.pyenv/shims:/home/user/.pyenv/bin:/home/user/.local/bin:/home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
[ Info: Julia executable: /home/user/lib/julia-1.7.1/bin/julia
[ Info: Trying to import PyCall...
┌ Warning: PyCall is already installed.  However, you may have trouble using
│ this Python executable because it is statically linked to libpython.
│ 
│ For more information, see:
│     https://pyjulia.readthedocs.io/en/latest/troubleshooting.html
│ 
│ Python executable:
│     /usr/bin/python
│ Julia executable:
│     /home/user/lib/julia-1.7.1/bin/julia
└ @ Main ~/.local/lib/python3.8/site-packages/julia/install.jl:90
>>> jl = julia.Julia(compiled_modules=False)
>>> jl.eval('using Pkg; Pkg.add("BetaML")')
/home/user/.local/lib/python3.8/site-packages/julia/core.py:703: FutureWarning: Accessing `Julia().<name>` to obtain Julia objects is deprecated.  Use `from julia import Main; Main.<name>` or `jl = Julia(); jl.eval('<name>')`.
  warnings.warn(
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
  No Changes to `~/.julia/environments/v1.7/Project.toml`
  No Changes to `~/.julia/environments/v1.7/Manifest.toml`
>>> 
sylvaticus commented 2 years ago

I can get of the warning if instead of:

import julia
julia.install()
jl = julia.Julia(compiled_modules=False)
jl.eval('using Pkg; Pkg.add("BetaML")')

I use

import julia
julia.install()
from julia.api import Julia
jl = Julia(compiled_modules=False)
jl.eval('using Pkg; Pkg.add("BetaML")')
sylvaticus commented 2 years ago

Sorry, just realised I posted this in PyCall.jl instead of pyjulia. Closing.