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

Python package #1

Closed
raphaelshirley opened this issue Oct 25, 2016 · 4 comments
Closed

Python package #1

raphaelshirley opened this issue Oct 25, 2016 · 4 comments

Comments

@raphaelshirley
Copy link

Hello,

Thank you very much for making this software available. I am trying to use the software with a view to applying it to galaxy deblending problems we are working on at the University of Sussex Astronomy Centre.

I am struggling to install the python package using 'python setup.py install' which throws the following error:

/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/tmplanbqx8y.cpp:4:21: error: cannot deduce type of initializer list because
std::initializer_list was not found; include <initializer_list>
for(auto i: {0,1,2}) {
^
1 error generated.
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/tmplanbqx8y.cpp:4:21: error: cannot deduce type of initializer list because
std::initializer_list was not found; include <initializer_list>
for(auto i: {0,1,2}) {
^
1 error generated.
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/tmplanbqx8y.cpp:4:13: warning: 'auto' type specifier is a C++11 extension
[-Wc++11-extensions]
for(auto i: {0,1,2}) {
^
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/tmplanbqx8y.cpp:4:19: warning: range-based for loop is a C++11 extension
[-Wc++11-extensions]
for(auto i: {0,1,2}) {
^
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/tmplanbqx8y.cpp:4:21: error: cannot deduce type of initializer list because
std::initializer_list was not found; include <initializer_list>
for(auto i: {0,1,2}) {
^
2 warnings and 1 error generated.
No C/C++ compiler with C++11 support found. Use the CC environment variable to specify a different compiler if you have one
Using None to enable C++11 support

It is clearly a c++ compiler problem. I seem to be able to compile the test code in the setup.py file using g++ on a mac with 'g++ -std=c++ main.cpp' but when that is run in setup.py it throws the error after setting the CC envirnoment variable to g++.

Do you have any suggestions for fixing this problem. I get the same errors when I try to use pip.

Sorry if I'm doing something stupid.

Best regards,

Dr Raphael Shirley
University of Sussex
raphael.shirley@sussex.ac.uk

@rtobar
Copy link
Contributor

rtobar commented Oct 26, 2016

Hi Raphael,

Can you please let me know which exact version of g++ are you using?

In addition, please try using the PYPROFIT_CXX11 environment variable (currently undocumented, I know) to specify an explicit switch to turn on the C++11 standard compliance in your compiler. In your case it would look like:

CC=g++ PYPROFIT_CXX11="-std c++" python setup.py install

Try also with CC=gcc if things don't work with g++.

I'll make a point on adding a bit of documentation about this additional environment variable.

@raphaelshirley
Copy link
Author

Hi,

Thanks, that has got me a bit further, I was trying to edit the environment variable using os.environ(). My g++ version is I think the most recent version of clang:

mps017431:examples rs548$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I have just moved over to a mac so am a bit inexperienced I'm afraid.

It now throws these two warnings but then seems to have installed correctly:

Using -std=c++11 to enable C++11 support
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/gsl_sf_gamma5nd9lvb4.c:1:1: warning:
type specifier missing, defaults to 'int' [-Wimplicit-int]
main (int argc, char **argv) {
^
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/gsl_sf_gamma5nd9lvb4.c:2:5: warning:
implicit declaration of function 'gsl_sf_gamma' is invalid in C99
[-Wimplicit-function-declaration]
gsl_sf_gamma();
^
2 warnings generated.

but then when I run python usage.py in examples I get the following:

Traceback (most recent call last):
File "usage.py", line 36, in
from profit_optim import profit_setup_data, profit_like_model, to_pyprofit_image
File "/Users/rs548/GitHub/pyprofit/examples/profit_optim.py", line 30, in
import pyprofit
SystemError: PyState_AddModule called on module with slots
Bus error: 10

Many thanks for your help. I aim to extend your code to fitting two galaxy profiles in blended images so will eventually be wanting to add a c++ class. I have included the full output from setup.py below incase it is helpful.

Best regards,

Raphael.

mps017431:pyprofit rs548$ CC=g++ PYPROFIT_CXX11="-std=c++11" python setup.py install
Using -std=c++11 to enable C++11 support
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/gsl_sf_gamma5nd9lvb4.c:1:1: warning:
type specifier missing, defaults to 'int' [-Wimplicit-int]
main (int argc, char **argv) {
^
/var/folders/zx/nzb1wy_d0yj1g8wznhz1ns68000930/T/gsl_sf_gamma5nd9lvb4.c:2:5: warning:
implicit declaration of function 'gsl_sf_gamma' is invalid in C99
[-Wimplicit-function-declaration]
gsl_sf_gamma();
^
2 warnings generated.
running install
running bdist_egg
running egg_info
writing pyprofit.egg-info/PKG-INFO
writing top-level names to pyprofit.egg-info/top_level.txt
writing dependency_links to pyprofit.egg-info/dependency_links.txt
reading manifest file 'pyprofit.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyprofit.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-x86_64/egg
running install_lib
running build_ext
building 'pyprofit' extension
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c pyprofit.cpp -o build/temp.macosx-10.6-x86_64-3.5/pyprofit.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/brokenexponential.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/brokenexponential.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/convolve.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/convolve.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/coresersic.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/coresersic.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/ferrer.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/ferrer.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/king.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/king.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/moffat.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/moffat.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/profit.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/profit.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/psf.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/psf.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/radial.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/radial.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/sersic.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/sersic.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/sky.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/sky.o -std=c++11
g++ -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/rs548/anaconda/include -arch x86_64 -DHAVE_GSL=1 -Ilibprofit -I/usr/local/include -I/Users/rs548/anaconda/include/python3.5m -c libprofit/src/utils.cpp -o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/utils.o -std=c++11
creating build/lib.macosx-10.6-x86_64-3.5
/usr/bin/clang++ -bundle -undefined dynamic_lookup -L/Users/rs548/anaconda/lib -arch x86_64 build/temp.macosx-10.6-x86_64-3.5/pyprofit.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/brokenexponential.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/convolve.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/coresersic.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/ferrer.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/king.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/moffat.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/profit.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/psf.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/radial.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/sersic.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/sky.o build/temp.macosx-10.6-x86_64-3.5/libprofit/src/utils.o -L/usr/local/lib -L/Users/rs548/anaconda/lib -lgsl -lgslcblas -o build/lib.macosx-10.6-x86_64-3.5/pyprofit.cpython-35m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9
creating build/bdist.macosx-10.6-x86_64
creating build/bdist.macosx-10.6-x86_64/egg
copying build/lib.macosx-10.6-x86_64-3.5/pyprofit.cpython-35m-darwin.so -> build/bdist.macosx-10.6-x86_64/egg
creating stub loader for pyprofit.cpython-35m-darwin.so
byte-compiling build/bdist.macosx-10.6-x86_64/egg/pyprofit.py to pyprofit.cpython-35.pyc
creating build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pyprofit.egg-info/PKG-INFO -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pyprofit.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pyprofit.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying pyprofit.egg-info/top_level.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.6-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
pycache.pyprofit.cpython-35: module references file
creating 'dist/pyprofit-1.0-py3.5-macosx-10.6-x86_64.egg' and adding 'build/bdist.macosx-10.6-x86_64/egg' to it
removing 'build/bdist.macosx-10.6-x86_64/egg' (and everything under it)
Processing pyprofit-1.0-py3.5-macosx-10.6-x86_64.egg
creating /Users/rs548/anaconda/lib/python3.5/site-packages/pyprofit-1.0-py3.5-macosx-10.6-x86_64.egg
Extracting pyprofit-1.0-py3.5-macosx-10.6-x86_64.egg to /Users/rs548/anaconda/lib/python3.5/site-packages
Adding pyprofit 1.0 to easy-install.pth file

Installed /Users/rs548/anaconda/lib/python3.5/site-packages/pyprofit-1.0-py3.5-macosx-10.6-x86_64.egg
Processing dependencies for pyprofit==1.0
Finished processing dependencies for pyprofit==1.0

@rtobar
Copy link
Contributor

rtobar commented Oct 26, 2016

Hi Raphael,

Thanks for the information. The compilation warnings are fine, and the module indeed compiled successfully, so the original problem I would say it is fixed, and I'm closing this ticket accordingly.

You were using g++ which is usually the name for the GNU C++ compiler, so I thought you were using that one. If you keep using clang, use cland/clang++ for compiling C/C++ programs. Maybe that would have picked up the correct standard automatically already.

Regarding the new problem, I'll create a second ticket to record it. I've seen this issue before elsewhere and I think I have an idea of what might be causing it.

On a final note, if you are actually planning to work mostly on C++ you might want to use libprofit (ICRAR/libprofit repository) directly instead of pyprofit, which simply wraps libprofit.

@raphaelshirley
Copy link
Author

Great, thanks. I wondered if there might be python 3 issue. We may decide to use c++ but plan on possibly using some old python code and python is our preferred code here for development. Thanks again for your help.

Best,

Raphael.

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

2 participants