Building CTranslate2 From Source


I’m trying to build CTranslate2 from source after customising the code in python/ file.
I’m using the guide here:
When I install the python package on the same computer where I built it, it works. But when I install the python package on a different computer from my private artifactory, it doesn’t work - when I’m running the following code:

from ctranslate2 import Translator

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/envs/arty_env/lib/python3.9/site-packages/ctranslate2/", line 21, in <module>
    from ctranslate2._ext import (
ImportError: cannot open shared object file: No such file or directory

I suspect that the C++ stuff is not included in the python package build (the resulting .whl file is just ~500kb).
I did pay attention to the “Attention” section in the install guide. It looks like the install directory of CTranslate2 in the computer that builds it is in “/home/ubuntu/my_ctranslate2”, so I did: export CTRANSLATE2_ROOT=/home/ubuntu/my_ctranslate2, but it didn’t help.

More Info:
This is my cmake command:


and I also ran sudo ldconfig

I would be happy if you can help me with this problem :slight_smile:

1 Like


Maybe try to add the path as in here:

If this does not work, feel free to open an issue at GitHub.

1 Like

Hi @ymoslem, thank you for your reply.

I also followed this suggestion.
I edited the LD_LIBRARY_PATH environment variable like this:


then I ran:

python bdist_wheel --dist-dir $CTRANSLATE2_ROOT

but the resulting .whl file is still small and doesn’t contain the file.
I will keep trying to make it work, I will open an issue in Github if I won’t make any progress.

1 Like

I opened an issue in GitHub: