bast / pybind11-demo Goto Github PK
View Code? Open in Web Editor NEWDemonstrates how to call a C++ class from Python using pybind11.
License: Mozilla Public License 2.0
Demonstrates how to call a C++ class from Python using pybind11.
License: Mozilla Public License 2.0
Hi, thanks for your work. I would like to run the code in conda environment that has different python version (3.7) than my base environment (3.8). I follow the example building and reaching the cmake ..
step i get this:
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so (found version "3.8.2")
-- Found PythonInterp: /home/msa/anaconda3/envs/pybind11_demo/bin/python3.7 (found version "3.7.9")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so
-- Performing Test HAS_CPP14_FLAG
-- Performing Test HAS_CPP14_FLAG - Success
-- pybind11 v2.3.dev0
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- LTO enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/msa/Documents/repos/pybind11-demo/build
So it already looks like PythonLibs
and PythonInterp
are found for different versions of python. Finishing the build with make
i obtain example.cpython-37m-x86_64-linux-gnu.so
. Testing it with python -c "import example"
gives the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: Python version mismatch: module was compiled for version 3.8, while the interpreter is running version 3.7.
What should i change (perhaps in CMakeLists.txt
) to be able to build this for my conda environment? I found a solution that gives a complicated setup.py
that nevertheless works, but for my own understanding id like a minimal example. Thanks in advance.
This was done because it seems difficult to get a consistent Python version for the interpreter, libraries, and pybind11. Until then testing only the compilation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.