Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems while following first steps from the docs #548

Closed
lamortenera opened this issue Dec 7, 2016 · 10 comments
Closed

Problems while following first steps from the docs #548

lamortenera opened this issue Dec 7, 2016 · 10 comments

Comments

@lamortenera
Copy link

Hi,

thanks for building such a great tool. I used R and Rcpp for a while and I loved it, so I am looking for a python equivalent. I gave up with Python.Boost because I didn't manage to setup boost under windows.

I tried to follow the first steps from the guide in https://pybind11.readthedocs.io/en/latest/basics.html, but I encountered some problems. I am using Windows 7 with Visual Studio 2015 and Python 3.5.

I am not a python guru and pretty bad at compiling things, so it is perfectly possible that the problems I encountered are just a reflection of that.

The first issue is that the first steps do not seem to be really the first. Do I have to install pybind11 in some way before compiling the test cases? If yes how? with pip? with python stetup.py install? At the very least I have to download something, maybe this could be clarified under "first steps". The docs say "Before getting started, make sure that development environment is set up to compile the included set of test cases.", but I don't understand what "set up to compile" exactly means. I assumed that I just had to download the latest pybind release from github, uncompress it, and create a build directory from the root of the git repository. I downloaded release 1.8.1.

The second issue I had was with cmake. The first thing I tried was the command cmake .. from the build directory. This command gave the following complaint:

Python config failure: Python is 64-bit, chosen compiler is 32-bit.

It took a while to understand that I had to issue the command cmake -A x64 ... This was written in the docs, well done for that, but I misunderstood it and expected potential issues to show up later, not at this stage. I am also wondering whether this could be automated by cmake, it sounds like something a build tool could figure out.

The third issue, and the one where I gave up, was the command cmake --build . --config Release --target pytest, which gave the following output:

MSBUILD : error MSB1009: Project file does not exist.

Looking at the project files created under the build directory, I assumed (but this is just speculation) that the command should have been:

cmake --build . --config Release --target RUN_TESTS

After issuing this command I got the following compilation errors:

'''
2>------ Build started: Project: RUN_TESTS, Configuration: Debug x64 ------
2> Test project C:/Users/amammana/Desktop/python_c_api/pybind11-1.8.1/pybind11-1.8.1/build
2> Start 1: example1
2> 1/18 Test #1: example1 .........................***Failed 0.25 sec
2> Start 2: example2
2> 2/18 Test #2: example2 .........................***Failed 0.34 sec
2> Start 3: example3
2> 3/18 Test #3: example3 .........................***Failed 0.19 sec
2> Start 4: example4
2> 4/18 Test #4: example4 .........................***Failed 0.17 sec
2> Start 5: example5
2> 5/18 Test #5: example5 .........................***Failed 0.20 sec
2> Start 6: example6
2> 6/18 Test #6: example6 .........................***Failed 0.18 sec
2> Start 7: example7
2> 7/18 Test #7: example7 .........................***Failed 0.24 sec
2> Start 8: example8
2> 8/18 Test #8: example8 .........................***Failed 0.20 sec
2> Start 9: example9
2> 9/18 Test #9: example9 .........................***Failed 0.21 sec
2> Start 10: example10
2> 10/18 Test #10: example10 ........................***Failed 0.21 sec
2> Start 11: example11
2> 11/18 Test #11: example11 ........................***Failed 0.28 sec
2> Start 12: example12
2> 12/18 Test #12: example12 ........................***Failed 0.19 sec
2> Start 13: example13
2> 13/18 Test #13: example13 ........................***Failed 0.19 sec
2> Start 14: example14
2> 14/18 Test #14: example14 ........................***Failed 0.18 sec
2> Start 15: example15
2> 15/18 Test #15: example15 ........................***Failed 0.19 sec
2> Start 16: example16
2> 16/18 Test #16: example16 ........................***Failed 0.21 sec
2> Start 17: example17
2> 17/18 Test #17: example17 ........................***Failed 0.16 sec
2> Start 18: issues
2> 18/18 Test #18: issues ...........................***Failed 0.17 sec
2>
2> 0% tests passed, 18 tests failed out of 18
2>
2> Total Test time (real) = 3.80 sec
2>
2> The following tests FAILED:
2> 1 - example1 (Failed)
2> 2 - example2 (Failed)
2> 3 - example3 (Failed)
2> 4 - example4 (Failed)
2> 5 - example5 (Failed)
2> 6 - example6 (Failed)
2> 7 - example7 (Failed)
2> 8 - example8 (Failed)
2> 9 - example9 (Failed)
2> 10 - example10 (Failed)
2> 11 - example11 (Failed)
2> 12 - example12 (Failed)
2> 13 - example13 (Failed)
2> 14 - example14 (Failed)
2> 15 - example15 (Failed)
2> 16 - example16 (Failed)
2> 17 - example17 (Failed)
2> 18 - issues (Failed)
2> Errors while running CTest
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "setlocal
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: "C:\Program Files\CMake\bin\ctest.exe" --force-new-ctest-process -C Debug
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmEnd
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmErrorLevel
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: exit /b %1
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :cmDone
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 8.
'''

Do you have any clue about what I should do?

Thanks very much in advance,
Alessandro

@dean0x7d
Copy link
Member

dean0x7d commented Dec 8, 2016

The readthedocs pages are tracking the latest docs for the master branch which has made some significant changes since v1.8.1 (preparing for v2.0). To build the test on the older version, use

cmake --build . --config Release --target check

But you may want to take a look at the python_example and cmake_example repositories which present a good starting point which you can expand on. (The two differ only in the build system: pure python or python + cmake.)

@wjakob Maybe it would be a good idea to configure readthedocs to show the stable docs by default and have those track the last tag, while the latest docs stay on master but not shown by default.

@wjakob
Copy link
Member

wjakob commented Dec 11, 2016

@dean0x7d: This issue will be mostly resolved when v2.x is pushed out, I don't expect much breakage following that.

@lramati
Copy link

lramati commented Dec 12, 2016

I am also experiencing issues with the documentation de-sync. I'm trying to understand exceptions, and the documentation (Also on the "stable" branch) says to look at tests/test_exceptions.cpp, yet no such file exists in the 1.8.1 tag, so I have no idea where to look.

After further rooting around, none of this functionality (custom exception types, exception registration, etc.) appears to exist at all in the 1.8.1 release, so having them in the documentation is incredibly misleading.

@wjakob
Copy link
Member

wjakob commented Dec 12, 2016

@firerogue: It's probably best if you use the master branch. It will become stable very shortly and blows 1.8.1 out of the water in terms of features :)

@wjakob
Copy link
Member

wjakob commented Dec 12, 2016

(confused by the doc inconsistency though -- I'm not sure how that could happen since the changes to feature and the docs are generally made in the same commit, which is where RTD gets its information from)

@wjakob
Copy link
Member

wjakob commented Dec 12, 2016

Ok, the issue with the stable docs is fixed.

@wjakob wjakob closed this as completed Dec 12, 2016
@jagerman
Copy link
Member

and blows 1.8.1 out of the water in terms of features

It also fixes quite a few bugs and issues discovered since 1.8.1. It's unstable in the sense that it's still a moving target, but it's rather more stable in terms of the amount of things being tested and fixed in it.

@stehol01
Copy link

stehol01 commented Mar 17, 2017

Hi, I would like to try pybind11 but it seems that i dont know how.
I tried to getting started with the python_example and the cmake_example which @dean0x7d mentioned, but somehow i dont get it! :P

Is there a step by step instruction guidline how to set up those examples? Something like a step by step tutorial for very beginners? Or a youtube video ...

I've already tried to getting both examples working but somehow i always end up with the following error if type the following words within my spyder IDE:

import python_example
python_example.add(1, 2)

Error:
AttributeError: module 'python_example' has no attribute 'add'

Why is this happening? I'm using python 3.6 and Anaconda. I also use VS2017.

Thank you for your help!

@NolenChen
Copy link

Hi, I also encountered lots of problems in compiling pybind11, it seems that lots of works should be done before the 'First Steps' in the tutorial.

@dean0x7d
Copy link
Member

Make sure you're following the stable docs: http://pybind11.readthedocs.io/en/stable/basics.html
(not latest or master).

Take a look at the example repositories:

  1. https://github.com/pybind/python_example -- Python-based build system if your primary project is Python and your extending to C++
  2. https://github.com/pybind/cmake_example -- CMake-based build system if your primary project is C++/CMake and you want Python bindings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants