Code Monkey home page Code Monkey logo

pybind11-demo's Issues

Building example in conda environment

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.

Test skips the Python import

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.