tfmoraes/python-gdcm

install in python:3.6-alpine image failed

summy00 opened this issue · 11 comments

@summy00 you need to install swig and ninja before.

@summy00 you need to install swig and ninja before.

I have installed by:

apk add swig

git clone -b 'release' --depth=1 https://github.com/ninja-build/ninja.git
cd ninja
./configure.py --bootstrap
cmake -Bbuild-cmake -H.
cmake --build build-cmake

git clone https://github.com/tfmoraes/python-gdcm.git
cd python-gdcm

but still error:
image
image

maybe I not install swig & ninja successfully

Try to export CMAKE_EXE and SWIG_EXE before the building:

$ export CMAKE_EXE=/CMAKE/PATH
$ export SWIG_EXE=/SWIG/PATH

Try to export CMAKE_EXE and SWIG_EXE before the building:

$ export CMAKE_EXE=/CMAKE/PATH
$ export SWIG_EXE=/SWIG/PATH

already done
maybe due to cmake -S command not work in alpine?
image

I managed to compile this way:

apk add swig ninja cmake gcc g++ patchelf
pip install python-gdcm

It compiles but doesn't import gdcm:

$ python -c "import gdcm"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/python-gdcm/gdcm.py", line 62, in <module>
    from _gdcm.gdcmswig import *
ModuleNotFoundError: No module named '_gdcm.gdcmswig'

after I change -SWIG_EXECUTABLE to -DSWIG_EXECUTABLE, and update submodule, it prompts:
image

after I run apk add ninja it can cmake with Ninja now...
and can build with python setup.py install, I will test it if it can import gdcm

build success, but cannot import
image

Exporting to LD_LIBRARY_PATH makes it work:

$ export LD_LIBRARY_PATH="/usr/local/lib"
$ python -c "import gdcm; print(gdcm.Version().GetVersion())"
3.0.8

I don't know why but "/usr/local/lib" is not in path list to find the shared libraries. But you can fix it exporting LD_LIBRARY_PATH.

So to install python-gdcm in python:3.6-alpine you have to run the following commands:

# Install swig, ninja, cmake, gcc, c++, patchelf
$ apk add swig ninja cmake gcc g++ patchelf

# Install python-gdcm
$ pip install python-gdcm

# export LD_LIBRARY_PATH to make system find `libpython.so`
$ export LD_LIBRARY_PATH="/usr/local/lib"

# Run Python, import GDCM and print GDCM version
python -c "import gdcm; print(gdcm.Version().GetVersion())"

So to install python-gdcm in python:3.6-alpine you have to run the following commands:

# Install swig, ninja, cmake, gcc, c++, patchelf
$ apk add swig ninja cmake gcc g++ patchelf

# Install python-gdcm
$ pip install python-gdcm

# export LD_LIBRARY_PATH to make system find `libpython.so`
$ export LD_LIBRARY_PATH="/usr/local/lib"

# Run Python, import GDCM and print GDCM version
python -c "import gdcm; print(gdcm.Version().GetVersion())"

thanks it work!