Closed TaWald closed 3 years ago
I found a solution: As expected cmake used the python2.7 executable.
To specify which python should be used you can use this snippet (adapt the paths to your own python executable, LIB and Include dir):
cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3.9 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPYTHON_LIBRARY:FILEPATH=/usr/lib/python3.9/config-3.9-x86_64-linux-gnu/libpython3.9.so ../SimpleElastix/SuperBuild
Should you not find the /usr/include/python3.9
directory with Python.h
inside, you have probably not installed the package python3.9-dev
. Do so via sudo apt-get install python3.9-dev
and you should be good to go. :+1:
Hello, when I follow the installation instructions from the docs "Compiling on Linux" I run into some issues. Sidenote: I run Ubuntu 20.04 with python2.7, python3.6/3.8/3.9 installed. My default python version refers to python2.7.
After building with cmake and running
python Packaging/setup.py install
successfully (with any python3 virtualenv) I open the virtualenv's python and try to callimport SimpleITK
.This results in the following error:
To me this seems like the module was compiled(?) or installed(?) erronously for python 2 instead of my virtualenvs python 3.9 version, since PyClass_Type is python 2 specific. To test this i created a virtualenv with a python 2.7 interpreter and it indeed works there. However I don't want it in python 2, but python 3.
What do I have to change in the installation process for it to be usable in my python 3 virtualenv?
Also in the "${BUILD_DIR}/SimpleITK-build/Wrapping/Python/build" directory there is a version for
lib.linux-x86_64-2.7/
andlib.linux-x86_64-3.9
. I'm not sure if this is relevant but it seems like at least the setup.py call deliberately tries to install it for the correct interpreter. Surprisingly it also installs it without error or warnings for my python 3 environment (which I would expect to fail when the cmake process did only compile a python 2 version).Here is the output of the
python .Packaging/setup.py install
call: