How do I install a 32-bit version of numpy - python

After much effort, I've finally got matplotlib, and all its dependencies, working harmoniously on Snow Leopard 10.6.8. I'd now like to tweak its configuration slightly to allow me to use my 32-bit installation of wxPython as its backend. The problem is that numpy (required by matplotlib) won't import when I use my 32-bit installation of Python 2.7.3 (python.org version). Googling for an hour or so has led me to believe that numpy can be built and installed as 32-bit by specifying CFLAGS and LDFLAGS inconjunction with setup.py. I'm not clear on what these flags do, and not surprisingly I've had no success using them. This is what I tried from within the downloaded numpy folder:
$ CLFLAGS=-m32 LDFLAGS=-m32 python setup.py install
I get a few error messages, but a 64-bit compatible version of numpy does arrive in my sitepackages folder. When I use the 32-bit interpreter however I get an error:
ImportError: dynamic module does not define init function (initmultiarray)
Am I right to think I can build a 32-bit numpy?

I just spent a couple days looking around and pulling my hair out so I thought I'd contribute here to what I found...
I had the same problem but just setting the flags would not work for me (but this is needed indeed) ... In my case I have a seperate 32-bit version of python, so I did:
CFLAGS="-m32" LDFLAGS="-m32" /util/linux32/bin/python setup.py install --prefix=/util/science/gfortran-4.4.6/linux32/
(don't worry about my gfortran thing in the prefix, lucky me had to test different compilers.. ;) )
but then I would get an error, the last line would say:
"RuntimeError: Broken toolchain: cannot link a simple C program"
but if I scrolled up I had:
gcc -pthread _configtest.o -o _configtest
_configtest.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
_configtest.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
failure.
removing: _configtest.c _configtest.o
and as you can see, no "-m32" flag in that call to gcc...
I tracked it back to the distutils install ; for me in there:
/util/linux32/lib/python2.7/distutils/ccompiler.py
and there is probably a more elegant solution than that, like getting the cflags value directly, but I am not a python girl so not sure how.. ;) I could probably figure it out but all I care about right now is to finally install numpy in 32-bit mode..
so anyways... line 693 of this python code, I changed
runtime_library_dirs=None, debug=0, extra_preargs=None,
to
runtime_library_dirs=None, debug=0, extra_preargs=['-m32'],
(in the function link_executable ; in case you have a different version of python... )
and voila... numpy in installed succesfully on a 64-bit machine in 32-bit mode.. I assume this would work for other modules too since it is related to distutils, not numpy.. ;)
hope this can help someone in the future and save some time!
Eve-Marie

You could try using the free version of EPD (or the full version is free if you're in academia):
http://www.enthought.com/products/epd_free.php/
This has a 32-bit version for mac with all of the key scientific stack packages including scipy, numpy and matplotlib.

Related

Building Pybind11 with setuptools for NEON intrinsics

I am trying to compile/bind a python extension written in C++ that uses NEON intrinsics using
setuptools build of PyBind11. But it keep giving me errors.
(arm_neon.h:28:2: error: "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
#error "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard")
To reproduce:
clone https://github.com/pybind/python_example
Add #include <arm_neon.h> to the main.cpp
Then I tried to install/build it using pip, this gives me the following error:
arm_neon.h:28:2: error: "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
#error "NEON intrinsics not available with the soft-float ABI. Please use -mfloat-abi=softfp or -mfloat-abi=hard"
So, I tried to add these options to the compiler flags by defining:
extra_compile_args=["-mfloat-abi=hard", "-O3", "-mcpu=native"]
But It still fails, and I see from the output:
clang: warning: argument unused during compilation: '-mfloat-abi=hard' [-Wunused-command-line-argument]
However there are some gcc parts in the output as well, so I tried to force the clang++ compiler by
setting:
os.environ["CC"] = "clang++"
In the top of setup.py
However I still get the same error.
(I have also tried a bunch of other tricks, but I feel that im just searching in the wrong direction so I will not list these).
I can compile an stand alone c++ file with clang so it seems like im doing something wrong with the setuptools configurations.
I am running a Macbook Pro M2.
So I figured it out. Turns out the default anaconda uses x86_64 and Rosetta instead of native ARM.
So you have to download the miniconda that supports ARM to make this work!

Installing graph-tool on Mac OS X (10.7) - already have Boost installed, but keep getting this error

I've been stuck on this issue for a while now. I'm trying to install graph-tool - http://graph-tool.skewed.de/download#macos - and I have the prereqs from following these steps, which the graph-tool site links to: https://gist.github.com/openp2pdesign/8864593
Instead of brew install, which didn't seem to give me all the files, I went to Boost's official site and downloaded from there properly, following these steps: http://www.boost.org/doc/libs/1_41_0/more/getting_started/unix-variants.html It's mainly getting a tar file and untarring it.
I then put my boost install here:
/usr/local/boost_1_55_0
I did a small C++ example and confirmed Boost works (using "Build a Simple Program Using Boost" from http://www.boost.org/doc/libs/1_41_0/more/getting_started/unix-variants.html.
Now the meat of the problem: trying to install graph-tool. In the very last step, I do
./configure PYTHON_EXTRA_LDFLAGS="-L/usr/local/bin"
(The PYTHON_EXTRA_LDFLAGS="-L/usr/local/bin" just makes the configure script find Python alright.)
But I get this error. (It finds Python fine, but not boost!)
...
================
Detecting python
================
checking for a Python interpreter with version >= 2.6... python
checking for python... /Users/daze/Library/Enthought/Canopy_64bit/User/bin/python
checking for python version... 2.7
checking for python platform... darwin
checking for python script directory... ${prefix}/lib/python2.7/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.7/site-packages
checking for python2.7... (cached) /Users/daze/Library/Enthought/Canopy_64bit/User/bin/python
checking for a version of Python >= '2.1.0'... yes
checking for a version of Python == '2.7.3'... yes
checking for the distutils Python package... yes
checking for Python include path... -I/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/include/python2.7
checking for Python library path... -L/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/config -lpython2.7
checking for Python site-packages path... /Users/daze/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages
checking python extra libraries... -ldl -framework CoreFoundation
checking python extra linking flags... -L/usr/local/bin
checking consistency of all components of python development environment... yes
graph-tool will be installed at: /Users/daze/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages
===========================
Using python version: 2.7.3
===========================
checking for boostlib >= 1.38.0... configure: error: We could not detect the boost
libraries (version 1.38 or higher). If you have a staged boost library (still not installed)
please specify $BOOST_ROOT in your environment and do not give a PATH to --with-boost option.
If you are sure you have boost installed, then check your version number looking in
<boost/version.hpp>. See http://randspringer.de/boost for more documentation.
Attempt 2: I then tried setting BOOST_ROOT properly:
In my ~/.bash_profile:
export BOOST_ROOT="/usr/local/boost_1_55_0"
But it still did no good, so I unset that.
Attempt 3: I then tried explicitly specifying where boost is installed:
./configure --with-boost="/usr/local/boost_1_55_0" PYTHON_EXTRA_LDFLAGS="-L/usr/local/bin"
But it still can't find boost, and yields that same error in the end of "We could not detect the boost libraries (version 1.38 or higher)."
It's been bugging me all day. I've read carefully, and went to the randspringer.de/boost site and saw this in the FAQ - http://www.randspringer.de/boost/faq.html#id2514912:
Q: I do not understand the configure error message
At configure time I get:
checking for boostlib >= 1.33... configure: error: We could not detect
the boost libraries (version 1.33 or higher). If you have a staged
boost library (still not installed) please specify $BOOST_ROOT in your
environment and do not give a PATH to --with-boost option. If you are
sure you have boost installed, then check your version number looking
in . See http://randspringer.de/boost for more
documentation.
I don't know if I use a staged version of boost. What is it and what
can I do ?
A: If you did not compile Boost by yourself you don't have a staged
version and you don't have to set BOOST_ROOT. Look here for an
explanation of different kind of installations.
If you are sure you have Boost installed then specify the directory
with
./configure --with-boost=your-boost-directory.
If it still does not work, please check the version number in
boost/version.hpp and compare it with the version requested in
configure.ac.
And I don't know what to see when comparing version numbers. There's nothing I found interesting there.
Hoping someone has at least an idea on what other approaches to take.
Hooray, my first chance to give back to Stack Overflow! I've been dealing with this issue myself the past 2 days.
Solution
Upgrade clang via Xcode
Make a symlink to boost that includes the version number
/usr/local/include/boost-1_55.0 -> ../Cellar/boost/1.55.0/include/boost
(included because I installed Boost using Brew and had this issue)
Edit the generation of CXXFLAGS in configure so that it looks like this:
old_cxxflags="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} -std=gnu++11 -stdlib=libc++"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler supports -std=gnu++11" >&5
$as_echo_n "checking whether C++ compiler supports -std=gnu++11... " >&6; }
Run
./configure --disable-sparsehash CXX="/usr/bin/clang++" PYTHON_EXTRA_LDFLAGS="-L/usr/local/bin"
Versions
OS: Mac OS X 10.8.5
Clang: Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
Graph-tool: 2.2.29.1
Boost: 1.55.0
Explanation
If you go through the configure code and try and compile the confdefs.h files made in configure, you'll see clang error out upon encountering the -Wno-unused-local-typedefs flag. This is the actual cause of the "We could not detect the boost libraries (version 1.33 or higher)" error, not the fact that it can't find the boost files. This issue is fixed with newer versions of clang.
The configure test for version number is goofy. It expects the boost include directory to contain the version number.
While running make, you may run into the following errors:
./../graph_adjacency.hh:26:10: fatal error: 'tuple' file not found
This is caused by referencing the wrong standard library [1]
./../graph_adaptor.hh:655:39: error: expected ';' in 'for' statement specifier
for(typeof(removed_edges.begin()) iter = removed_edges.begin();
./../graph_adaptor.hh:655:39: error: use of undeclared identifier 'tier'
This is caused by referencing the wrong C++ standard (c++11 instead of gnu++11)
References
[1] No member named 'forward' in namespace 'std'
[2] I'm having some trouble with C++11 in Xcode
I think that you're currently pointing --with-boost to the boost parent directory, not the boost libraries.
Try
./configure --with-boost="/usr/local/boost_1_55_0/libs/" PYTHON_EXTRA_LDFLAGS="-L/usr/local/bin"

Windows / PyPi / PyCharm linker errors when compiling some cython modules

currently, i am working with PyCharm on Windows, and i tried to install some packages via PyPi. For convinience, i used the integrated functionality of PyCharm, which does essentially the same as the shell easy_install.
However, when installing packages which have to be compiled with gcc, i get some errors. I already browsed a lot of questions here on stackoverflow because of the former errors, and managed to overcome some of the errors (using mingw64, removing the -mno-cygwin parameter from the setup scripts etc) but now i'm totally stuck on this one:
build\temp.win-amd64-2.7\Release\cpyamf\amf0.o:amf0.c:(.text+0xb912): undefined reference to `__imp_PyExc_ImportError'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/bin/ld.exe: build\temp.win-amd64-2.7\Release\cpyamf\amf0.o: bad reloc address 0x78 in section `.data'
collect2.exe: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
The error occurs on the installation of PyAMF and Twisted, which use cython for some parts. I couldn't find a solution for that one yet.
Thanks in advance.
I solved it with help from the folks at #python on freenode. Or better: found a workaround.
The problem was basically that i used 64 bit python on windows, which doesn't really work well with minGW64 and stuff.
I installed 32 bit Python, edited the distutils.cfg fixed the -mno-cygwin problem and it basically worked out of the box.
So if anyone else encounters this problem: Use 32 bit Python.

py-bcrypt installing on win 7 64bit python

Trying to install py-bcrypt on win7. Python is 64bit. First error unable to find vcvarsall.bat. Googled a bit learned that i needed to install mingw. installed it now this
C:\tools\python_modules\py-bcrypt-0.2>python setup.py build -c mingw32
running build
running build_py
running build_ext
building 'bcrypt._bcrypt' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\Python27\include -Ic:\Python27\PC -c bcrypt/bcrypt_python.c -o b
d\temp.win-amd64-2.7\Release\bcrypt\bcrypt_python.o
bcrypt/bcrypt_python.c:29:26: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c:29:38: error: expected declaration specifiers or '...' before 'u_int16_t'
bcrypt/bcrypt_python.c:29:49: error: expected declaration specifiers or '...' before 'u_int8_t'
bcrypt/bcrypt_python.c: In function 'bcrypt_encode_salt':
bcrypt/bcrypt_python.c:56:2: error: too many arguments to function 'encode_salt'
bcrypt/bcrypt_python.c:29:6: note: declared here
error: command 'gcc' failed with exit status 1
no idea what to do next. guess i'll just not use bcrypt and try something else. Any other suggestions?
There is a compiled version of py-bcrypt for windows. You can visit https://bitbucket.org/alexandrul/py-bcrypt/downloads to download the .exe file and install.
I've looked at the bcrypt source, and can't figure out why you're getting the error you are (don't have a Windows system at hand to test on right now). Though looking at the pybcrypt issue tracker it looks like it has other Windows compilation problems, so it's probably not just you. At a guess though, adding "--std=C99" to the gcc arguments via extra_compile_args might fix at least some of the errors.
Aside from that, there are a couple of alternatives -
Bcryptor is another C-extension bcrypt implementation which may compile for your system.
Passlib is a general password hashing library. While it relies on bcryptor/pybcrypt for bcrypt support, it has builtin support for a number of other password hashes that may work for you - such as SHA512-Crypt or PBKDF2-HMAC-SHA512
Cryptacular is another general password hashing library. On Windows, it provides both BCrypt and PBKDF2-HMAC-SHA512 password hashes. (I'd link straight to those, but the documentation won't quite let me).
I stumbled upon this rather old thread while trying to get py-bcrypt installed (via pip) on Windows 7 using VS2012. Apparently, this still doesn't work (I also get the "missing vcvars.bat" error).
There is a dedicated Windows fork for py-bcrypt called py-bcrypt-w32, which I could install without any problems using
pip install py-bcrypt-w32
I had the same issue and I fixed it by applying the patch found at this link:
http://code.google.com/p/py-bcrypt/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&groupby=&sort=&id=1
py-bcrypt_11.patch
Had to apply it manually.
From that thread, the source of the problem is
According to http://groups.google.com/group/mpir-devel/msg/2c2d4cc7ec12adbb (flags defined under the various windows OS'es ,cygwins,mingw's and other's) its better to use _WIN32 instead of _MSC_VER, Together with the change from bzero to memset this compiles both under MSVC and MingW32.
Hope that helps!
supposing you are using mingw64, you should change _MSC_VER in _WIN32 on ifdefs into bcrypt.c, bcrypt_python.c and pybc_blf.h
I had this same problem with python 3.4.1, and none of the previous answers worked. I eventually got the Visual Studio 2010 64-bit compiler working, and hence both cryptacular and py-bcrypt installed with easy_install. See my detailed answer here: https://stackoverflow.com/a/27033824/3800244
It's 2016 and I have faced same issue. Download the wheel directly from https://bitbucket.org/alexandrul/py-bcrypt/downloads and then run following
pip install <whl-file>

How to install 64-bit Python on Solaris?

I am trying to install Python 2.6 on Solaris by building the source on Solaris machine. I installed one this way and it appears that it is 32-bit. I downloaded some source tar ball as Linux or Unix for this purpose. Everything works well but I need 64-bit Python.
I looked up the Python download site and there is no separate installation for a 64-bit Python.
That makes me think that there must be some option while running configure and/or install commands to install Python. I tried reading README.txt of the installation but could not find any info. I am very new to installations on "Unix" like systems.
How can I install 64-bit Python on Solaris?
I would strongly suggest seeing if you can get away with the 32 bit version of Python. If your new to compiling stuff on Solaris, this will save you many headaches. However, it is possible, and I do have a working 64 bit version of Python. I'm using cc: Sun C 5.8 2005/10/13 to compile. Additionally, I've already compiled 64-bit version of readline and ncurses.
My configure line looks like this:
../Python-2.6.1/configure CCSHARED="-KPIC" LDSHARED="cc -xarch=generic64 -G -KPIC" LDFLAGS="-xarch=generic64 -L/opt/tools/lib -R/opt/tools/lib -L/opt/tools/ssl/lib -ltermcap -lz -R $ORIGIN/../lib" CC="cc" CPP="cc -xarch=generic64 -E -I/opt/tools/include -I/opt/tools/include/ncurses -I/opt/tools/include/readline" BASECFLAGS="-xarch=generic64 -I/opt/tools/include -I/opt/tools/include/ncurses" OPT="-xO5" CFLAGS="-xarch=generic64 -I/opt/tools/include -I/opt/tools/include/ncurses -I/opt/tools/include/readline" CXX="CC -xarch=generic64 -I/opt/tools/include -I/opt/tools/include/ncurses" --prefix=/opt/tools/python-2.6.1 --enable-64-bit --without-gcc --disable-ipv6 --with-ssl=openssl --with-ncurses --with-readline
Additionally, I modified these two lines in Modules/Setup.local to include the required locations:
readline readline.c -I/opt/tools/include/readline -L/opt/tools/lib -lreadline -ltermcap
_ssl _ssl.c -I/opt/tools/ssl/include -L/opt/tools/ssl/lib -lssl -lcrypto
Now, just pray you don't need to compile in some Sybase bindings or some other 64-bit libraries.
It's currently an acknowledged bug that Solaris 64-bit support is suboptimal, but that bug report looks to contain some flags that you might want to use. See also this mailing list posting.

Categories

Resources