0

I'm trying to follow this seemingly simple tutorial on how to make an executable using Cython.

The python file I'm using contains the following:

#cython: language_level=3
print("hello world")

I compiled this file into a .c file by running the following command:

cython --embed test.pyx

I compiled the program with these arguments.

gcc -Os -I /usr/local/Caskroom/miniconda/base/envs/cython_test/include/python3.8 -L /usr/local/Caskroom/miniconda/base/envs/cython_test/lib -lpython3.8 test.c -o test

However, after compiling the program, and attempting to run it, I receive this error.

dyld: Library not loaded: @rpath/libpython3.8.dylib
   Referenced from: ./test
   Reason: image not found
Abort trap: 6

I was able to successfully compile and run the executable using a non-conda python environment of python 3.7, so that leads me to believe that the library files that came with my conda environment are having an effect here.

Matthewj
  • 1,932
  • 6
  • 26
  • 37
  • 1
    Looks like your PATH environment variable needs to be updated so the folder containing the python library will be searched for the lib when you run your program. What OS are you on? @Matthewj – Todd Feb 21 '20 at 04:04
  • I’m on Mac OS 10.15.3 – Matthewj Feb 21 '20 at 05:57
  • You need either to add the right folder to LD_LIBRARY_PATH, or to build with --rpath, see for example https://stackoverflow.com/q/8482152/5769463 – ead Feb 21 '20 at 05:58

0 Answers0