[Numpy-discussion] numpy import problem
Hello, finally after sorting out some homemade problems I managed to compile numpy-1.0b1. If I then start it from the directory where I compiled it, it works fine. However after I installed numpy with python setup.py install --prefix=/scratch/python2.4 I get the error message: Python 2.4.3 (#7, Aug 2 2006, 18:55:46) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2 Type help, copyright, credits or license for more information. import numpy Traceback (most recent call last): File stdin, line 1, in ? File /scratch/python2.4/lib/python2.4/site-packages/numpy/__init__.py, line 39, in ? import linalg File /scratch/python2.4/lib/python2.4/site-packages/numpy/linalg/__init__.py, line 4, in ? from linalg import * File /scratch/python2.4/lib/python2.4/site-packages/numpy/linalg/linalg.py, line 24, in ? from numpy.linalg import lapack_lite ImportError: /scratch/python2.4/lib/python2.4/site-packages/numpy/linalg/lapack_lite.so: undefined symbol: atl_f77wrap_zgemv__ I suppose I have to set a path somewhere to the directory where atlas is installed. How do I do this? Hanno -- Hanno Klemm [EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Examples of basic C API usage?
On Tuesday 08 of August 2006 05:18, Bill Baxter wrote: I see Pyrex and SWIG examples in numpy/doc but there doesn't seem to be an example of just a simple straightforward usage of the C-API. For instance make a few arrays by hand in C and then call numpy.multiply() on them. So far my attempts to call PyArray_SimpleNewFromData all result in segfaults. Anyone have such an example? --Bill Have you looked here? http://numeric.scipy.org/numpydoc/numpy-13.html#pgfId-36640 Karol -- written by Karol Langner wto sie 8 15:45:16 CEST 2006 - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy and matplotlib
On Tuesday 08 August 2006 17:02, George Gumas wrote: I downloaded numpy 1 and matplotlib and when running numpy i get the error message below from matplotlib._ns_cntr import * RuntimeError: module compiled against version 90709 of C-API but this version of numpy is 100 How do I go about chaning the version of rither numpy or matplotlib This question is more appropriate for the mpl list, and it was discussed there late last week. The next matplotlib release will support numpy beta 1 and 2. Darren - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy and matplotlib
Matplotlib needs to be recompiled against the latest Numpy.They should release a new version compatible with Numpy 1.0 beta soon.--bbOn 8/9/06, George Gumas [EMAIL PROTECTED] wrote:I downloaded numpy 1 and matplotlib and when running numpy i get the error message below from matplotlib._ns_cntr import * RuntimeError: module compiled against version 90709 of C-API but this version of numpy is 100 How do I go about chaning the version of rither numpy or matplotlib Thanks George -Using Tomcat but need to do more? Need to support web services, security?Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/numpy-discussion - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] NumPy, shared libraries and ctypes
Hello all With the nice ctypes integration in NumPy, and with Python 2.5 which will include ctypes around the corner, a remote possibility exists that within the next year or two, I might not be the only person that wants to use NumPy with ctypes. This is probably going to mean that this someone is going to want to build a shared library for use with ctypes. This is all well and good if you're using a build tool that knows about shared libraries, but in case this person is stuck with distutils, here is what we might want to do. Following this thread from SciPy-dev: http://projects.scipy.org/pipermail/scipy-dev/2006-April/005708.html I came up with the following plan. As it happens, pretending your shared library is a Python extension mostly works. In your setup.py you can do something like this: config = Configuration(package_name,parent_package,top_path) config.add_extension('libsvm_', define_macros=[('LIBSVM_EXPORTS', None), ('LIBSVM_DLL', None)], sources=[join('libsvm-2.82', 'svm.cpp')], depends=[join('libsvm-2.82', 'svm.h')]) First caveat: on Windows, distutils forces the linker to look for an exported symbol called inityourextensionname. In your code you'll have to add an empty function like this: void initlibsvm_() {} This gets us a compiled Python extension, which also happens to be a shared library on every platform I know of, which is Linux and Windows. Counter-examples anyone?. Next caveat: on Windows, shared libraries aka DLLs, typically have a .dll extension. However, Python extensions have a .pyd extension. We have a utility function in NumPy called ctypes_load_library which handles finding and loading of shared libraries with ctypes. Currently, shared library extensions (.dll, .so, .dylib) are hardcoded in this function. I propose we modify this function to look something like this: def ctypes_load_library(libname, loader_path, distutils_hack=False): ... If distutils_hack is True, instead of the default mechanism (which is currently hardcoded extensions), ctypes_load_library should do: import distutils.config so_ext = distutils.sysconfig.get_config_var('SO') to figure out the extension it should use to load shared libraries. This should make it reasonably easy for people to build shared libraries with distutils and use them with NumPy and ctypes. Comments appreciated. Someone checking something along these lines into SVN appreciated more. A solution that doesn't make me want to cry appreciated most. Thanks for reading. Regards, Albert P.S. As it happens, the OOF2 guys have already created a SharedLibrary builder for distutils, but integrating this into numpy.distutils is probably non-trivial. http://www.ctcms.nist.gov/oof/oof2.html - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Examples of basic C API usage?
Ah, great. That is helpful, though it does seem to be a bit outdated.--bbOn 8/8/06, Karol Langner [EMAIL PROTECTED] wrote:On Tuesday 08 of August 2006 05:18, Bill Baxter wrote: I see Pyrex and SWIG examples in numpy/doc but there doesn't seem to be an example of just a simple straightforward usage of the C-API. For instance make a few arrays by hand in C and then call numpy.multiply() on them.So far my attempts to call PyArray_SimpleNewFromData all result in segfaults. Anyone have such an example? --BillHave you looked here?http://numeric.scipy.org/numpydoc/numpy-13.html#pgfId-36640 Karol--written by Karol Langnerwto sie8 15:45:16 CEST 2006-Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easierDownload IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/numpy-discussion - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] NumPy, shared libraries and ctypes
On 8/9/06, Albert Strasheim [EMAIL PROTECTED] wrote: Next caveat: on Windows, shared libraries aka DLLs, typically have a .dllextension. However, Python extensions have a .pyd extension.We have a utility function in NumPy called ctypes_load_library which handles finding and loading of shared libraries with ctypes. Currently, sharedlibrary extensions (.dll, .so, .dylib) are hardcoded in this function.I propose we modify this function to look something like this: def ctypes_load_library(libname, loader_path, distutils_hack=False):...If distutils_hack is True, instead of the default mechanism (which iscurrently hardcoded extensions), ctypes_load_library should do: import distutils.configso_ext = distutils.sysconfig.get_config_var('SO')to figure out the extension it should use to load shared libraries. Thisshould make it reasonably easy for people to build shared libraries with distutils and use them with NumPy and ctypes.Wouldn't it make more sense to just rename the .pyd generated by distutils to .dll or .so? Especially since the .pyd generated by distutils won't actually be a python extension module. This renaming could be automated by a simple python script that wraps distutils. The addition of the init{modulename} function could also be done by that script. --bb - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy and matplotlib
We're waiting on some possible changes in the numpy c-api before scipy. Hopefully we will have a working release in the next week. On 8/8/06, Bill Baxter [EMAIL PROTECTED] wrote: Matplotlib needs to be recompiled against the latest Numpy. They should release a new version compatible with Numpy 1.0 beta soon. --bb On 8/9/06, George Gumas [EMAIL PROTECTED] wrote: I downloaded numpy 1 and matplotlib and when running numpy i get the error message below from matplotlib._ns_cntr import * RuntimeError: module compiled against version 90709 of C-API but this version of numpy is 100 How do I go about chaning the version of rither numpy or matplotlib Thanks George - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] NumPy, shared libraries and ctypes
Bill Baxter wrote: Wouldn't it make more sense to just rename the .pyd generated by distutils to .dll or .so? Especially since the .pyd generated by distutils won't actually be a python extension module. This renaming could be automated by a simple python script that wraps distutils. The addition of the init{modulename} function could also be done by that script. The strategy of post-processing after the setup() is not really robust. I've encountered a number of packages that try to things like that, and I've never had one work right. And no, it won't solve the init{modulename} problem, either. It's a problem that occurs at build-time, not import-time. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] NumPy, shared libraries and ctypes
Dear Albert, I have started to use numpy and ctypes together and I've been quite pleased. Thanks for your efforts and writings on the wiki. On the topic of ctypes but not directly following from your email: I noticed immediately that the .ctypes attribute of an array is going to be a de-facto array interface, and wondered whether it would actually be better to write some code that takes the __array_struct__ interface and exposes that as an object with ctypes-providing attributes. This way, it could be used by all software exposing the __array_struct__ interface. Still, even with today's implementation, this could be acheived with numpy.asarray( my_array_struct_object ).ctypes. Back to your email: I don't understand why you're trying to build a shared library with distutils. What's wrong with a plain old c-compiler and linker (and mt.exe if you're using MS VC 8)? You can build shared libraries this way with Makefiles, scons, Visual Studio, and about a billion other solutions that have evolved since early C days. I can understand the desire of getting python setup.py install to work, but I suspect spawning an appropriate subprocess to do the compilation would be easier and more robust than attempting to get distutils to do something it's not designed for. (Then again, to see what numpy distutils can do, well, let's just say I'm amazed.) Along these lines, I noticed that ctypes-itself seems to have put some hooks into setup.py to perform at least part of the configure/make dance on linux, although I haven't investigated any further yet. Perhaps that's a better way to go than bending distutils to your will? Finally, the ctypes_load_library() function was broken for me and so I just ended up using the appropriate ctypes calls directly. (I should report this bug, I know, and I haven't yet... Bad Andrew.) But the bigger issue for me is that this is a ctypes-level convenience function, and I can't see why it should be in numpy. Is there any reason it should go in numpy and not into ctypes itself where it would surely receive more review and widespread use if it's useful? Albert Strasheim wrote: Hello all With the nice ctypes integration in NumPy, and with Python 2.5 which will include ctypes around the corner, a remote possibility exists that within the next year or two, I might not be the only person that wants to use NumPy with ctypes. This is probably going to mean that this someone is going to want to build a shared library for use with ctypes. This is all well and good if you're using a build tool that knows about shared libraries, but in case this person is stuck with distutils, here is what we might want to do. Following this thread from SciPy-dev: http://projects.scipy.org/pipermail/scipy-dev/2006-April/005708.html I came up with the following plan. As it happens, pretending your shared library is a Python extension mostly works. In your setup.py you can do something like this: config = Configuration(package_name,parent_package,top_path) config.add_extension('libsvm_', define_macros=[('LIBSVM_EXPORTS', None), ('LIBSVM_DLL', None)], sources=[join('libsvm-2.82', 'svm.cpp')], depends=[join('libsvm-2.82', 'svm.h')]) First caveat: on Windows, distutils forces the linker to look for an exported symbol called inityourextensionname. In your code you'll have to add an empty function like this: void initlibsvm_() {} This gets us a compiled Python extension, which also happens to be a shared library on every platform I know of, which is Linux and Windows. Counter-examples anyone?. Next caveat: on Windows, shared libraries aka DLLs, typically have a .dll extension. However, Python extensions have a .pyd extension. We have a utility function in NumPy called ctypes_load_library which handles finding and loading of shared libraries with ctypes. Currently, shared library extensions (.dll, .so, .dylib) are hardcoded in this function. I propose we modify this function to look something like this: def ctypes_load_library(libname, loader_path, distutils_hack=False): ... If distutils_hack is True, instead of the default mechanism (which is currently hardcoded extensions), ctypes_load_library should do: import distutils.config so_ext = distutils.sysconfig.get_config_var('SO') to figure out the extension it should use to load shared libraries. This should make it reasonably easy for people to build shared libraries with distutils and use them with NumPy and ctypes. Comments appreciated. Someone checking something along these lines into SVN appreciated more. A solution that doesn't make me want to cry appreciated most. Thanks for reading. Regards, Albert P.S. As it happens, the OOF2 guys have already created a SharedLibrary builder for distutils, but integrating this into numpy.distutils is probably non-trivial. http://www.ctcms.nist.gov/oof/oof2.html
[Numpy-discussion] astype char conversion
Hi, Sorry if this is silly question, but should this work to convert from int8 to character type? a = array([104, 105], dtype=N.int8) a.astype('|S1') I was a bit surprised by the output: array([1, 1], dtype='|S1') Thanks a lot, Matthew - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] NumPy, shared libraries and ctypes
Andrew Straw wrote: Back to your email: I don't understand why you're trying to build a shared library with distutils. What's wrong with a plain old c-compiler and linker (and mt.exe if you're using MS VC 8)? You can build shared libraries this way with Makefiles, scons, Visual Studio, and about a billion other solutions that have evolved since early C days. I can understand the desire of getting python setup.py install to work, but I suspect spawning an appropriate subprocess to do the compilation would be easier and more robust than attempting to get distutils to do something it's not designed for. (Then again, to see what numpy distutils can do, well, let's just say I'm amazed.) Along these lines, I noticed that ctypes-itself seems to have put some hooks into setup.py to perform at least part of the configure/make dance on linux, although I haven't investigated any further yet. Perhaps that's a better way to go than bending distutils to your will? Well, wrapper he's writing destined for scipy, so python setup.py build must work. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy and matplotlib
Darren Dale wrote: On Tuesday 08 August 2006 17:02, George Gumas wrote: I downloaded numpy 1 and matplotlib and when running numpy i get the error message below from matplotlib._ns_cntr import * RuntimeError: module compiled against version 90709 of C-API but this version of numpy is 100 This error may happen if you forgot to rebuild all matplotlib against the new numpy. Did you try recompiling everything by removing the build directory of matplotlib ? David - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion