Can't run examples on Mac

52 views
Skip to first unread message

Zaw

unread,
Sep 26, 2011, 1:48:34 PM9/26/11
to Zunzun.com discussion group
Hello there,

first: brilliant library. second, I have some difficulties running the
examples please: I'm on Mac OSX 10.5.8 and python 2.7. Im new to
python.

Inside the Simple Examples directory, when I run:

python NonLinearFit2D.py

I get the following error:


/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp:1: error: bad
value (native) for -march= switch
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp:1: error: bad
value (native) for -mtune= switch
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp:1: error: bad
value (native) for -march= switch
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp:1: error: bad
value (native) for -mtune= switch
Traceback (most recent call last):
File "NonLinearFit2D.py", line 21, in <module>
equation.SetGAParametersAndGuessInitialCoefficientsIfNeeded() #
estimate initial parameters if needed
File "/Users/ahmedalazzawi/My/Works/METER/pythonEquations/
pythonequations/Examples/../../pythonequations/
EquationBaseClasses.py", line 630, in
SetGAParametersAndGuessInitialCoefficientsIfNeeded
self.EstimateInitialCoefficientsUsingCPP()
File "/Users/ahmedalazzawi/My/Works/METER/pythonEquations/
pythonequations/Examples/../../pythonequations/
EquationBaseClasses.py", line 1489, in
EstimateInitialCoefficientsUsingCPP
weave.inline(code, parameterNameList, support_code = supportCode,
extra_compile_args = Equation.compiler_flags_for_weave_inline,
compiler = Equation.compiler_name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/site-packages/scipy/weave/inline_tools.py", line 355, in
inline
**kw)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/site-packages/scipy/weave/inline_tools.py", line 482, in
compile_function
verbose=verbose, **kw)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/site-packages/scipy/weave/ext_tools.py", line 367, in
compile
verbose = verbose, **kw)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/site-packages/scipy/weave/build_tools.py", line 272, in
build_extension
setup(name = module_name, ext_modules = [ext],verbose=verb)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/site-packages/numpy/distutils/core.py", line 186, in
setup
return old_setup(**new_attr)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/
lib/python2.7/distutils/core.py", line 169, in setup
raise SystemExit, "error: " + str(msg)
scipy.weave.build_tools.CompileError: error: Command "/usr/bin/g++-4.0
-fno-strict-aliasing -fno-common -dynamic -pipe -O2 -DNDEBUG -g -
fwrapv -O3 -Wall -I/opt/local/Library/Frameworks/Python.framework/
Versions/2.7/lib/python2.7/site-packages/scipy/weave -I/opt/local/
Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-
packages/scipy/weave/scxx -I/opt/local/Library/Frameworks/
Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/
include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/
include/python2.7 -c /opt/local/Library/Frameworks/Python.framework/
Versions/2.7/lib/python2.7/site-packages/scipy/weave/scxx/
weave_imp.cpp -o /var/folders/fJ/fJ-1N+DyHR066CYcW5knPk+++TI/-Tmp-/
ahmedalazzawi/python27_intermediate/
compiler_3dde639b68a04d91df1e300015fa088d/opt/local/Library/Frameworks/
Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/weave/
scxx/weave_imp.o -march=native -O2" failed with exit status 1


Any help please? Thank you.

zunzun.com

unread,
Sep 27, 2011, 8:50:54 AM9/27/11
to Zunzun.com discussion group
I don't have a Mac for testing, so please bear with me. At the top of
your error listing I see:

> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/
> python2.7/site-packages/scipy/weave/scxx/weave_imp.cpp:1: error: bad
> value (native) for -march= switch

which means your compiler does not accept the compiler directive

march=native

If you look near the top of the file EquationBaseClasses.py at about
line 70, you will find:

# for weave.inline() C++ compilation, change as needed for your
CPU and compiler
if sys.platform == 'win32': # try to pre-detect MSVC++, MinGW32 or
GCC and optimize appropriately.
if weave.platform_info.msvc_exists():
compiler_name = 'msvc'
compiler_flags_for_weave_inline = ['/O2']
else:
compiler_name = 'mingw32'
compiler_flags_for_weave_inline = ['-O2']
else:
compiler_name = 'gcc'
compiler_flags_for_weave_inline = ['-march=native', '-O2']


Please make the last line shown above to read:

compiler_flags_for_weave_inline = ['-O2']

and try again.

James

Zaw

unread,
Oct 5, 2011, 5:42:39 AM10/5/11
to Zunzun.com discussion group
Great! So now its working, this the output of python
FixedCoefficient.py

Exponential 2D
SSQABS: 1.80392579859
Coefficient a: 0.092
Coefficient b: 0.444968625759

X: 5.357 Y 0.376 Model: 0.997732800245 Abs. Error: 0.621732800245 Rel.
Error: 1.6535446815 Percent Error: 165.35446815
X: 5.457 Y 0.489 Model: 1.04313133533 Abs. Error: 0.554131335333 Rel.
Error: 1.13319291479 Percent Error: 113.319291479
X: 5.797 Y 0.874 Model: 1.21350931414 Abs. Error: 0.339509314141 Rel.
Error: 0.388454592838 Percent Error: 38.8454592838
X: 5.936 Y 1.049 Model: 1.2909353854 Abs. Error: 0.241935385397 Rel.
Error: 0.230634304478 Percent Error: 23.0634304478
X: 6.161 Y 1.327 Model: 1.42687252161 Abs. Error: 0.0998725216125 Rel.
Error: 0.0752618851639 Percent Error: 7.52618851639
X: 6.697 Y 2.054 Model: 1.81119742039 Abs. Error: -0.242802579606 Rel.
Error: -0.118209629798 Percent Error: -11.8209629798
X: 6.731 Y 2.077 Model: 1.8388072322 Abs. Error: -0.238192767803 Rel.
Error: -0.11468115927 Percent Error: -11.468115927
X: 6.775 Y 2.138 Model: 1.87516327866 Abs. Error: -0.262836721341 Rel.
Error: -0.122935791086 Percent Error: -12.2935791086
X: 8.442 Y 4.744 Model: 3.93715521834 Abs. Error: -0.806844781658 Rel.
Error: -0.170076893267 Percent Error: -17.0076893267
X: 9.769 Y 7.068 Model: 7.10594532313 Abs. Error: 0.0379453231309 Rel.
Error: 0.00536860825281 Percent Error: 0.536860825281
X: 9.861 Y 7.104 Model: 7.40287854155 Abs. Error: 0.298878541552 Rel.
Error: 0.0420718667725 Percent Error: 4.20718667725

Now I have another question please, how to get the same functionality
of the Website from a python code that I can write? In other words:

if I have a set of X, Y values, how to call the python equations files
in the package that I have downloaded on my machine to get a set of
possible fitting functions, with their coefficients?

where to put my python file (in which I call the library)? and how to
import the library? For instance, the example above gives the
coefficients but not the equation... is there any tutorial which you
can refer to please on how to call the library from a python code and
get a set of possible equations? or does that have to be through a Web
service of yours?...

Thank you so much.

zunzun.com

unread,
Oct 5, 2011, 6:08:39 AM10/5/11
to Zunzun.com discussion group
On Oct 5, 4:42 am, Zaw <a_n_alazz...@hotmail.com> wrote:
>
> Now I have another question please, how to get the same functionality
> of the Website from a python code that I can write? In other words:
>
> if I have a set of X, Y values, how to call the python equations files
> in the package that I have downloaded on my machine to get a set of
> possible fitting functions, with their coefficients?

Please look in the Examples directory. All of the examples should now
run on your computer.


> where to put my python file (in which I call the library)? and how to
> import the library? For instance, the example above gives the
> coefficients but not the equation... is there any tutorial which you
> can refer to please on how to call the library from a python code and
> get a set of possible equations? or does that have to be through a Web
> service of yours?...

Please look in the Examples directory.


James
Reply all
Reply to author
Forward
0 new messages