Open piyush-bagad opened 5 years ago
Hi @piyush-bagad, did you only clone the repo or also build the Python module? The latter step is needed, but I just realized this wasn't described in the readme. I just commited a piece of text to the readme to describe the process.
By the way, the module currently does not work with Blender 2.80. Are you using that, or still using 2.7x?
@paulmelis Hi, Thanks for the response.
No I am using it with 2.79. Also, I am not able to build the python module. I used python setup.py build_ext --inplace
and this throws up the following error:
readply.cpp:245:30: warning: ISO C++11 does not allow conversion from string literal to 'char *'
[-Wwritable-strings]
static char *kwlist[] = {"plyfile", "blender_face_indices", "blender_vertex_colors_per_face...
^
readply.cpp:245:41: warning: ISO C++11 does not allow conversion from string literal to 'char *'
[-Wwritable-strings]
static char *kwlist[] = {"plyfile", "blender_face_indices", "blender_vertex_colors_per_face...
^
readply.cpp:245:65: warning: ISO C++11 does not allow conversion from string literal to 'char *'
[-Wwritable-strings]
static char *kwlist[] = {"plyfile", "blender_face_indices", "blender_vertex_colors_per_face...
^
3 warnings generated.
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/opt/gettext/include -I./rply -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c rply/rply.c -o build/temp.macosx-10.14-x86_64-3.7/rply/rply.o -std=c++11
error: invalid argument '-std=c++11' not allowed with 'C'
error: command 'clang' failed with exit status 1
Does this module work with usual python or only with blender's python?
Ah, you're on macOS, with clang as compiler. It seems clang is tripping over the -std=c++11
argument when compiling the C file (while it is needed for readply.cpp
). I just updated setup.py
in 14e987f3512633fd3286882bcad8efe9623633b6, can you try to see if that fixes it?
The module works with regular Python as well.
@paulmelis
I cloned the newly committed repo. The build went through with a few warnings but the original error of module not found still persists.
Here is the exact output:
running build_ext
building 'readply' extension
creating build
creating build/temp.macosx-10.14-x86_64-3.7
creating build/temp.macosx-10.14-x86_64-3.7/rply
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/opt/gettext/include -I./rply -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c readply.cpp -o build/temp.macosx-10.14-x86_64-3.7/readply.o
readply.cpp:245:30: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
static char *kwlist[] = {"plyfile", "blender_face_indices", "blender_vertex_colors_per_face...
^
readply.cpp:245:41: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
static char *kwlist[] = {"plyfile", "blender_face_indices", "blender_vertex_colors_per_face...
^
readply.cpp:245:65: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
static char *kwlist[] = {"plyfile", "blender_face_indices", "blender_vertex_colors_per_face...
^
3 warnings generated.
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/opt/gettext/include -I./rply -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c rply/rply.c -o build/temp.macosx-10.14-x86_64-3.7/rply/rply.o
rply/rply.c:379:18: warning: variable 'ply' is uninitialized when used here [-Wuninitialized]
error_cb(ply, "Incompatible type system");
^~~
rply/rply.c:375:14: note: initialize the variable 'ply' to silence this warning
p_ply ply;
^
= NULL
rply/rply.c:481:18: warning: variable 'ply' is uninitialized when used here [-Wuninitialized]
error_cb(ply, "Incompatible type system");
^~~
rply/rply.c:478:14: note: initialize the variable 'ply' to silence this warning
p_ply ply;
^
= NULL
2 warnings generated.
creating build/lib.macosx-10.14-x86_64-3.7
clang++ -bundle -undefined dynamic_lookup -L/usr/local/opt/gettext/lib -I/usr/local/opt/gettext/include build/temp.macosx-10.14-x86_64-3.7/readply.o build/temp.macosx-10.14-x86_64-3.7/rply/rply.o -L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/sqlite/lib -o build/lib.macosx-10.14-x86_64-3.7/readply.cpython-37m-darwin.so
copying build/lib.macosx-10.14-x86_64-3.7/readply.cpython-37m-darwin.so ->
Well, it looks like the build succeeded. So do you have a file readply.cpython-37m-darwin.so
in the top-level directory? If so, what happens if you run python -c 'import readply'
in that same directory?
Yeah actually on running the file mesh_readply.py
, the error of Module not found occurs. But in the usual python console, it is working perfectly!
Thanks a ton!
Also, can I simply replace the import_mesh.ply()
function call by this new (faster) method in Blender? Will I have to do anything additional?
Yeah actually on running the file
mesh_readply.py
, the error of Module not found occurs. But in the usual python console, it is working perfectly!Thanks a ton!
Also, can I simply replace the
import_mesh.ply()
function call by this new (faster) method in Blender? Will I have to do anything additional?
Unfortunately, it is not a direct replacement of the bpy.ops.import_mesh.ply()
function in blender. For now, the easiest way to get a PLY file into Blender with this module is to use
$ blender -P mesh_readply.py -- file.ply
Note that you can load an existing blender file first, followed by importing the PLY file using
$ blender myfile.blend -P mesh_readply.py -- file.ply
There has been some development on improving import speed of PLY (plus OBJ and STL) in this year's Google Summer of Code projects, but it seems the import improvements are currently not in a shape to get included in Blender 2.8x. See this devtalk thread for more information on the current state. Maybe that work will be restarted at some point, but until then, this module is an (imperfect) alternative.
I would like to draw your attention to this: So when I am using readply(path)
inside a python3.7 console, it is working. But when I am doing that with blender -P mesh_readply.py -- my_ply_file.ply
, it still gives the ModuleNotFound error. Here is the full output
Read prefs: /Users/--/Library/Application Support/Blender/2.79/config/userpref.blend
found bundled python: /Applications/Blender/blender.app/Contents/Resources/2.79/python
Added anaconda library to path
Traceback (most recent call last):
File "/Users/--/Desktop/projects/anthro/code/other_repos/blender-ply-import/mesh_readply.py", line 13, in <module>
from readply import readply
ImportError: No module named 'readply'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/--/Desktop/projects/anthro/code/other_repos/blender-ply-import/mesh_readply.py", line 17, in <module>
from readply import readply
ImportError: No module named 'readply'
Blender quit
That is really strange. The first ImportError
should be caught by the exception handler, although it might get reported because the second attempt at importing readply
(with updated sys.path
) fails in the handler.
Could you insert a line print(sys.path)
so that the importing section in mesh_readply.py
reads as below and then retry blender -P mesh_readply.py -- my_ply_file.ply
?
sys.path.insert(0, '.')
try:
from readply import readply
except ImportError:
scriptdir = os.path.split(os.path.abspath(__file__))[0]
sys.path.insert(0, scriptdir)
print(sys.path) # Add this line
from readply import readply
Secondly, the Python version used by your Blender installation might not be the same as the one you used to build the module. Can you provide the output of these two commands?
$ blender -b --python-expr 'import sys; print(sys.version)'
$ python -c 'import sys; print(sys.version)'
Yeah I build the module using py3.7 while Blender uses 3.5.
Read prefs: /Users/piyushbagad/Library/Application Support/Blender/2.79/config/userpref.blend
found bundled python: /Applications/Blender/blender.app/Contents/Resources/2.79/python
Added anaconda library to path
3.5.3 (default, May 29 2017, 11:05:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
Blender quit
3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)]
I'll try to git clone again and build with Blender python.
I just pushed 0c53eb9500b34cad8b7a5dd5db6be15d8c048b71 which should help. Try compiling the module under Blender directly, using
$ blender -b -P setup.py
Yup I tried this. But the old error pops up again :(
Read prefs: /Users/piyushbagad/Library/Application Support/Blender/2.79/config/userpref.blend
found bundled python: /Applications/Blender/blender.app/Contents/Resources/2.79/python
Added anaconda library to path
running build_ext
building 'readply' extension
creating build
creating build/temp.macosx-10.6-intel-3.5
creating build/temp.macosx-10.6-intel-3.5/rply
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -I/usr/local/opt/gettext/include -I./rply -I/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/site-packages/numpy/core/include -I/Applications/Blender/blender.app/Contents/Resources/2.79/python/include/python3.5m -c readply.cpp -o build/temp.macosx-10.6-intel-3.5/readply.o
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use
the libc++ standard library instead [-Wstdlibcxx-not-found]
readply.cpp:16:10: fatal error: 'Python.h' file not found
#include <Python.h>
^~~~~~~~~~
1 warning and 1 error generated.
error: command 'clang' failed with exit status 1
Well, this is a different error than earlier. Now the Python include files cannot be found. Does the file /Applications/Blender/blender.app/Contents/Resources/2.79/python/include/python3.5m/Python.h
exist?
I should really try this out on a macOS system myself, but don't have one handy here, sorry
Hey, I was able to run it on Mac without an issue. But on some other Ubuntu system, it again has this error
(base) piyushb@****:~/projects/anthro/code/blender-ply-import$ /home/users/piyushb/installations/blender-2.80-linux-glibc217-x86_64/2.80/python/bin/python3.7m setup.py build_ext --inplace
running build_ext
building 'readply' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/rply
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/sources/build_linux/deps/Release/sqlite/include -I/home/sources/build_linux/deps/Release/bzip2/include -I/home/sources/build_linux/deps/Release/lzma/include -I/home/sources/build_linux/deps/Release/zlib/include -fPIC -fPIC -I./rply -I/home/users/piyushb/installations/blender-2.80-linux-glibc217-x86_64/2.80/python/lib/python3.7/site-packages/numpy/core/include -I/home/users/piyushb/installations/blender-2.80-linux-glibc217-x86_64/2.80/python/include/python3.7m -c readply.cpp -o build/temp.linux-x86_64-3.7/readply.o
In file included from /usr/include/c++/5/cstdint:35:0,
from readply.cpp:28:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
readply.cpp: In function ‘PyObject* readply(PyObject*, PyObject*, PyObject*)’:
readply.cpp:232:71: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
static char *kwlist[] = {"plyfile", "vertex_values_per_loop", NULL};
^
readply.cpp:232:71: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
error: command 'gcc' failed with exit status 1
On running the following command independently, with flag -std=c++11
, It does not show the error.
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/sources/build_linux/deps/Release/sqlite/include -I/home/sources/build_linux/deps/Release/bzip2/include -I/home/sources/build_linux/deps/Release/lzma/include -I/home/sources/build_linux/deps/Release/zlib/include -fPIC -fPIC -I./rply -I/home/users/piyushb/installations/blender-2.80-linux-glibc217-x86_64/2.80/python/lib/python3.7/site-packages/numpy/core/include -I/home/users/piyushb/installations/blender-2.80-linux-glibc217-x86_64/2.80/python/include/python3.7m -c readply.cpp -o build/temp.linux-x86_64-3.7/readply.o
But I am not able to find the source code where this command is being called
Hi Fixed it using this commit https://github.com/paulmelis/blender-ply-import/commit/14e987f3512633fd3286882bcad8efe9623633b6
Yeah, I know, the setup.py
way of building the module is very limited. And clang isn't helping as it should just ignore the -std=c++11
argument for a C file. So by removing that option in that commit helps for one case, but not for the other, nor in the general sense.
But it's building for you now? And have you found the module file? I see you're using the --inplace
option, but that leaves the module file witin the build
dir. If possible use blender -b -P setup.py
, that will make sure the module gets copied to the current directory.
I've reverted the removal of -std=c++11
in ce91cc2364a0137a080f27ca7cf4d7630b221860, so now your clang build on macOS is broken again
With 4276e74d3e2e06e9081388d3bc40ea6fd06f84e1 I've turned the main source code into C instead C++. That should fix the compile issue you were seeing on macOS.
Hey, I'm trying to import readply module but it shows these error:
:readply.c(16): fatal error C1083:Can't open the include file: “Python.h”: No such file or directory,error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
Hey, I'm trying to import readply module but it shows these error:
:readply.c(16): fatal error C1083:Can't open the include file: “Python.h”: No such file or directory,error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
I use windows, the blender version is 3.6
@Coder-ZZY not sure what goes wrong in your case. Can you paste all the output from the build command? I usually don't develop on Windows, so it might be something specific for that platform that goes wrong.
Also, please see this note from the readme:
Note: the official Blender binaries do not include the Python headers. So you still need a full Python installation somewhere to build the
readply
extension.
I git cloned this repo and tried to run the test script mesh_readply.py. But it is not running. I need help regarding this.