eos
eos copied to clipboard
Python bindings: "ImportError: arg(): could not convert default argument into a Python object [...]"
Hi, I have the following problem with using eos-py. After successfully installing eos-py with: pip install eos-py
I get the following error while trying to import the eos library (inside python):
import eos Traceback (most recent call last): File "
", line 1, in ImportError: arg(): could not convert default argument into a Python object (type not registered yet?). Compile in debug mode for more information.
I would appreciate your help
Hi,
Hmm, I remember getting this exact error a few weeks ago with a different module, actually. I don't remember what the solution was though, but I do remember that I think it had nothing to do with the code itself. It was perhaps an issue with caching, the compiler, Python versions, something like that. I think after I cleared all build caches and did a clean Release/RelWithDebInfo build, it worked fine again.
I don't think this has anything to do with eos specifically. I think you'll just need to play around a bit with the compilation process, start from a clean build directory, perhaps try a different (64-bit) Python version, perhaps clone eos from GitHub and try installing from there. Perhaps even follow the suggestion in the error message, compile in debug mode, and see what happens.
Sorry that I don't remember more or can't be of more direct help. If you find out more, please let us know here.
Thanks for the quick response Patrik, I will try playing some more with the installation process as you suggested.
Thanks again for sharing this awesome package
I get the error too. I compiled in debug mode and tried to import the eos library (inside python):
import eos
Traceback (most recent call last):
File "
I need your kind help. Thank you so much.
I change my default g++/gcc version to g++-7/gcc-7 and rebuild it. The import works fine now.
@huntkao Interesting! What was the previous gcc version that you used that didn't work?
Another idea I had was to completely remove the build directory, and then rebuild with CMAKE_CXX_STANDARD=17
. This is/should be the default actually, but since in your error it mentions akrzemi1::nullopt_t
, it looks like something has gone wrong with the build and it's using C++14 fallback types.
I remember now that I think I got this error in a similar scenario, and it also went away once I used a clean build directory, made sure CMAKE_CXX_STANDARD
is on 17
, and used a recent compiler.
@barhilleli, this should also help you.
My previous gcc version was gcc-6 (6.5.0 actually). When I changed to gcc-7 and rebuilt, I left *CXX_FLAGS as its default values.
Thanks for your quick response.
@huntkao Thanks! It is indeed still a bit of a mystery. But I think if one makes sure to have a clean build directory and to build with CMAKE_CXX_STANDARD=17
(which is/should be the default), then it works (and should also work with gcc-6, unless there's some regression on that compiler).
Hi,
Does anybody have more update on this ? I have the exact same issue. I tried all the solutions listed, no success..
Thank you
Anyone encountering this, please specify more information, otherwise it's not helpful. At the very least:
- OS (Win/Linux/macOS)
- Python version, including 32/64 bit
- What eos version, and how was it installed? Via
pip
? - If you've installed from GitHub sources, give details on how and what you did.
Hi,
- MacOS.
- Python 3.7.2, 64bit
- eos 1.1.1 I tried both pip, and manually building it with cmake : After cloning the repo, I set "EOS_GENERATE_PYTHON_BINDINGS" to "ON" in the CMakeLists.txt. I run cmake, then "make python-bindings". I get the shared library eos.cpython-37m-darwin.so. I then copy it in the site-packages of my Python project. I am compiling through PyCharm. I get the same error : "ImportError: arg(): could not convert default argument 'vertex_definitions: akrzemi1::nullopt_t' in method '<class 'eos.morphablemodel.MorphableModel'>.init' into a Python object (type not registered yet?)"
Many thanks
Hi @BenjBarral,
Okay, I think on macOS/XCode, you will need to make sure that the #if
here (and the same in eos/cpp17/variant.hpp
) is adjusted, so XCode/AppleClang chooses the C++17 branch. Is __cplusplus
not >= 201703L
in your AppleClang version? Which XCode version are you using?
If you self-compile, also make sure to do a Release
build (I think CMake defaults to Debug
but it depends on the generator). You can also do pip install .\eos
to install from your local/potentially modified sources.
In any case just make sure it uses the C++17 branch in those files and it should be okay. I hope XCode by now supports these C++17 features (it still didn't fully half a year or a year ago). If in doubt, make sure you got the very latest XCode version.
Hi Patrik,
Thanks a lot, this was indeed the problem. Xcode 9 (and AppleClang9) do not fully support C++17. Updating to Xcode 10 solved the problem.
Thanks again !
Benjamin
Hi @patrikhuber i am able to pip install but not able to import it.
My system info: **- Ubuntu 16.4, 64 bit
- Python 3.5.2
- eos 1.1.1
- GNU 7.4.0**
I cloned the repo and ran the setup.py to build (does this count as proper way to build?), I did not get any errors, below output of it.
the error persists, could you please tell me what other things should be checked. Thanks in advance.
Hey @BenjBarral, aah great! That's fantastic, and I'm sure it'll help other people as well! Thanks.
@vineethbabu, if you get any error with akrzemi1::optional
or mpark::variant
when doing import eos
in Python, then you haven't compiled with C++17/CMAKE_CXX_STANDARD 17
.
Thank you @patrikhuber for your super quick reply. I changed my default gcc version to gcc 7.4 and installed a newer version of python, now the error is gone.
could you please tell me if there is a way to obtain .obj, mesh and texture from the python code?. Thanks in advance.
@vineethbabu Great!
For your question, this is very off-topic here. Please have a look at demo.py
, the documentation, play around with it and learn, and you'll find out.