janestreet / pythonlib

A library to help writing wrappers around ocaml code for python
MIT License
101 stars 12 forks source link

python module installation installs a shared library for the wrong OS #5

Open nilsbecker opened 3 years ago

nilsbecker commented 3 years ago

hi,

at least i think that's what's happening. i do pip install ocaml and then in IPython i try to import ocaml. this gives:

 dlopen(/Users/nbecker/Apps/anaconda3/lib/python3.7/site-packages/ocaml/sharedlib/ocaml.so, 2): no suitable image found.  Did find:
    /Users/nbecker/Apps/anaconda3/lib/python3.7/site-packages/ocaml/sharedlib/ocaml.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00

i'm on macos; could it be that pip install installs a .so for linux?

nilsbecker commented 3 years ago

I noticed this same error when i was using the dune rule (copy# ...) to copy the compiled .bc.so file to a .so loadable in python -- python does not like the extra information written at the beginning of the binary by dune. that might be another reason for the error.

finally, i was initially under the impression that i have to install this pip package in order to use pythonlib, which is not true. it's unclear to me now for what exactly it is needed? is it only an example provided with the blog post? or is it necessary to use the magic commands in a jupyter notebook? it would be nice if this were documented somewhere

geofflangenderfer commented 3 years ago

I tried the following on manjaro linux

❯ pip install ocaml
Defaulting to user installation because normal site-packages is not writeable
Collecting ocaml
  Downloading ocaml-0.0.11-py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 1.1 MB/s 
Collecting wurlitzer
  Downloading wurlitzer-2.1.0-py2.py3-none-any.whl (6.2 kB)
Installing collected packages: wurlitzer, ocaml
Successfully installed ocaml-0.0.11 wurlitzer-2.1.0
❯ python -c "import ocaml"
Fatal error: executable program file not found
davy39 commented 3 months ago

Hello, I'm getting the same error "Fatal error: executable program file not found" with ubuntu 24.04, and some Docker containers I'm trying to build for using with jupyterlab. Any hints on how to get ocaml magics to work with jupyter ?