JuliaPy / PyCall.jl

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

Incompatible with PythonCall.jl #1056

Closed LilithHafner closed 1 month ago

LilithHafner commented 12 months ago

I can't load this package and PythonCall.jl in the same Julia session without error

x@x dev % julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _' |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using PyCall, PythonCall
    CondaPkg Found dependencies: /Users/x/.julia/packages/PythonCall/qTEA1/CondaPkg.toml
    CondaPkg Dependencies already up to date
ERROR: InitError: Python: SystemError: initialization of _datetime did not return an extension module
Python stacktrace:
 [1] <module>
   @ 
SYSTEM (REPL): showing an error caused an error
ERROR: Python: 
SYSTEM (REPL): caught exception of type PyException while trying to handle a nested exception; giving up

julia> 
x@x dev % julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _' |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using PythonCall, PyCall
    CondaPkg Found dependencies: /Users/x/.julia/packages/PythonCall/qTEA1/CondaPkg.toml
    CondaPkg Dependencies already up to date
julia(25115,0x206e11b40) malloc: *** error for object 0x137f60050: pointer being freed was not allocated
julia(25115,0x206e11b40) malloc: *** set a breakpoint in malloc_error_break to debug

[25115] signal (6): Abort trap: 6
in expression starting at REPL[1]:1
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 8260202 (Pool: 8255891; Big: 4311); GC: 12
zsh: abort      julia
x@x dev % julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores
Environment:
  JULIA_EDITOR = code
LilithHafner commented 12 months ago

Adding documentation pointing to https://juliapy.github.io/PythonCall.jl/stable/pycall/#Tips would help, making the error give that hint would be even better.

PallHaraldsson commented 1 month ago

Is this still relevant, or was it actually?

I mean the link no longer works, should point to current docs on using together, which claim possible. I do not want to claim possible to use together, if actually not possible in some edge cases, but I think it might not be impossible if done correctly (maybe only on 1.10.5?).

Should PyCall be deprecated? And/or at the README least point PythonCall.jl, as an alternative? I meant to open an issue/PR, to that effect, but hesitate because of this open one...

stevengj commented 1 month ago

In principle, it should be possible to use both PyCall and PythonCall simultaneously, if you configure them to use the same Python installation?

stevengj commented 1 month ago

Alternatively, since PythonCall can use any Python determined at runtime, possibly you can tell it to use PyCall's python at runtime if you load the latter first.

stevengj commented 1 month ago

This is documented here: https://juliapy.github.io/PythonCall.jl/stable/faq/#Can-I-use-PythonCall-and-PyCall-together?

So I think this issue can be closed?