Building with Python3 links against Boost Python2 library
See original GitHub issueOn a Ubuntu 16.04 box where I have both Python2 as well as Python3:
$ ls /usr/lib/x86_64-linux-gnu/libboost_python*.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so
/usr/lib/x86_64-linux-gnu/libboost_python.so
$ ll /usr/lib/x86_64-linux-gnu/libboost_python.so
lrwxrwxrwx 1 root root 49 Dec 22 14:16 /usr/lib/x86_64-linux-gnu/libboost_python.so -> /usr/lib/x86_64-linux-gnu/libboost_python-py27.so
When I install the osmium Python bindings with Python3 and compile osmium from source
python3 -m pip install osmium
the resulting shared object links against Python2:
ldd /usr/local/lib/python3.6/dist-packages/osmium/_osmium.cpython-36m-x86_64-linux-gnu.so | grep python
libboost_python-py27.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0 (0x00007f91eeff3000)
which results in undefined symbol errors when trying to use osmium from a Python3 script:
ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0: undefined symbol: PyClass_Type
Is there a way for pyosmium to check if the build process is meant for Python2 or Python3 and then link against 2.x or 3.x Boost.Python shared libraries, respectively?
Workaround is a bit ugly but does the job:
python3 -m pip uninstall osmium
rm -rf ~/.cache/pip/wheels/
rm /usr/lib/x86_64-linux-gnu/libboost_python.so
ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so /usr/lib/x86_64-linux-gnu/libboost_python.so
python3 -m pip install osmium
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Boost.Python tries to link Python 2.7 even though Python 3.6 is ...
Python3 instead of Boost.Python (2) to avoid issues with legacy code, but Boost insists on trying to find the Python2 LIB file anyway....
Read more >How to build the Boost Python for both Python2 and Python3?
I was trying to build the Boost 1.65.1 for both versions of Python I use: ./bootstrap.sh --with-python=python2 --with-python=python3.
Read more >Linking Python and C++ with Boost.python - shocksolution.com
Boost is a project to create open-source libraries for C++. There are a lot of nice tools available through Boost, one of which...
Read more >Building Extensions with boost.python
Using bjam. bjam is a standard tool for building boost library itself. Thus it is preferable way to build Python extensions based on...
Read more >Boost-1.80.0 - Linux From Scratch!
bootstrap.sh --prefix=/usr --with-python=python3 && ./b2 stage -j <N> threading=multi link=shared. To run the Boost.Build's regression test, issue pushd ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The initial post above has a workaround at the bottom.
(In the context of robosat what you also can do is remove the
extract
import and setup inrobosat/tools/__main__.py
We only need osmium for turning features in osm.pbf files into polygons. And you could do that e.g. in a Docker container with Ubuntu 16.04 and its default Python 3.5)Thanks @daniel-j-h … applied your patch to the quick-n-dirty
docker-pytorch
I got going here: https://github.com/mapbox/robosat/issues/29#issuecomment-401860959Sorry I missed it in the first place.