简体   繁体   中英

Pytest not able to find shared object .so

I'm using ghostscript as a dependency in my docker container. For that, I've installed both the library and C deps:

FROM python:3.9.5-slim-buster

...
RUN apt-get install -y ... ghostscript python3-tk` # and requirements.txt with ghostscript.

REPL in the container works as expected:

>>> from ctypes.util import find_library
>>> find_library("gs")
'libgs.so.9'
>>> import tkinter
>>> 

and the file does exist in the container: /usr/lib/x86_64-linux-gnu/libgs.so.9

However, when running plain pytest it is not found:

os.environ["LD_LIBRARY_PATH"] += os.pathsep + "/usr/lib/x86_64-linux-gnu/"

import tkinter
from ctypes.util import find_library

assert find_library("gs") is not None

and fails.

I have no idea of what I'm missing here, can't seem to find relevant issues with pytest and shared objects. I reinstalled all libs and deleted.pytest_cache just in case with no luck. Is there at least a workaround to load the shared object directly just for pytest?

It seems like this was caused by the pyfakefs extension, which creates a fake filesystem, so an issue has been raised there

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM