I'm new to Mac so please bear with me.
I'm using snow leopard 10.6.4 at the moment.
I want to install numpy and scipy, so I downloaded the python2.6,numpy and scipy dmg files from their official site. However, I'm having problem import numpy:
Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper
Can anyone shed some light to this problem?
Sounds as though you might be trying to use a 32-bit library from a 64-bit Python. Looks like there's an unofficial 64-bit Numpy available for Snow Leopard.
EDIT: The Python 2.6 .dmg available here is indeed 32-bit. (Specifically, it's a universal binary containing both i386 and ppc versions). The same is true of the regular numpy and scipy .dmg releases available here. (How do I know? See below!) So if you use those releases together you should be fine.
But you're not fine - so my guess is you're not using the version of Python from the 2.6 .dmg you downloaded. If you're running an executable python script, e.g.:
$ ./my-script.py
then you could try specifying the Python you're using explicitly on the command line. Looks like the MacPython .dmg installs to /usr/local/bin/python, so try:
$ /usr/local/bin/python2.6 myscript.py
Any joy?
How I determined the architecture the contents of those .dmg files are built for...
Mount the .dmg (i.e. double-click it to open a volume)
Use gunzip and pax to unpack the package contents to a local directory, e.g.:
$ mkdir tmp
$ cd tmp
$ gunzip -c /Volumes/Universal\ MacPython\ 2.6/MacPython.mpkg/Contents/Packages/PythonUnixTools-2.6.pkg/Contents/Archive.pax.gz | pax
Use file to examine binary files in the package contents
$ file Versions/2.6/bin/python
Versions/2.6/bin/python: Mach-O universal binary with 2 architectures
Versions/2.6/bin/python (for architecture ppc): Mach-O executable ppc
Versions/2.6/bin/python (for architecture i386): Mach-O executable i386
I had the same error message when I was trying my freshly-installed numpy and scipy in python2.7 on Mac OSX 10.6.8 . Later I found out that there were two .dmg for python2.7:
numpy-1.6.2-py2.7-python.org-macosx10.3.dmg
numpy-1.6.2-py2.7-python.org-macosx10.6.dmg
It was the package in 10.3.dmg giving me the error message about multiarray.so.
After installing the one in 10.6.dmg, I got rid of this error message.
I had problems with numpy until I installed in a virtualenv, now I don't have any issues. I would definitely suggest trying that.
for snow leopard 64 bit i used the following man
http://blog.hyperjeff.net/?p=160
just execute and you are good to go.
Also look at the comments ( new AMD ...)
building numpy works all the time. but for scipy you need to provide the numpy config files.
install gfortran .....
No need to use MacPorts or Fink.
Use the Python 2.6 installer and this Numpy installer. I think you need to have Numpy installed first, then install Scipy, and everything will work auto-magically. I remember that for a while, I needed to explicitly append the path to the site-packages directory at the top of my scripts for Python to know where to look.
The best way to manage packages on OS X is Fink (not MacPorts :) ). They have good Python, NumPy, and SciPy support.
Why use a package manager? because you will not only get NumPy and SciPy, but also many other programs that you will inevitably need, all with a single point of entry (basically the install command of the manager). This is much more convenient than having to hunt for specific compiled versions of the programs that you want to install.
Why Fink? because Fink is reputedly more stable than MacPorts, and has many more packages.
In case this is useful to someone, I also had problems installing numpy's binaries on OSX. The installer complained telling me that:
You cannot install numpy 1.5.1 on this volume. numpy requires System Python 2.6 to install.
Long story short: “System Python” means “python from python.org” and “2.6” means really 2.6, not 2.5 and not 2.7. So, go and find the installer for the version of python that numpy wants and then all is great.
On my first attempt I understood numpy's error as telling me that I had an outdated python, so I got the latest version (2.7 at the time), but numpy kept complaining all the same. Only after a careful reading of the message I understood that it really wanted 2.6 and not any other version. I trashed the first installation (found in /Library/Frameworks/Python.framework) and installed 2.6 after that. Finally numpy was happy to install and everything was fine.
I've spent countless hours browsing the web, trying to get various python packages working in OS X. In the end, I found the easiest solution was to either switch entirely to Ubuntu or run Ubuntu in Virtualbox from within OS X (all free of cost).
Using Ubuntu's package manager, apt-get, virtually any package you want will work out of the box after one simple install command. It was a huge rush the first time I got numpy, scipy, and matplotlib up and running in less than a minute.
$ sudo apt-get install python-numpy python-scipy python-matplotlib
I still get a mini-rush every time I do that. Not sure if there is a debian package for the module you want? Typically there is, and you can search for, say, python's lxml module with:
$ apt-cache search lxml | grep python
Related
I'm quit new in using python. The current version I'm using is 2.7. I need to employ function mncontour in minuit which requires the installation of natgrid as additional toolkit for matplotlib. I downloaded natgrid 0.2.1 with a file named setup.py in it. I ran this setup.py through python shell without reaching any error. But it seems that the installation was not succeed. Anyone has any idea how the installation can be done? Many thanks.
Liang
Could you please provide some more information on this topic.
what operating system you are working with ( some offer more support than others for python)
have you installed python headers, and a C/C++ compiler in your environment? ( numerical libraries might require native code to speed up the computation)
Have you tried a package manager for python ( such as easy or pip)? Both work on both windows and unixes, and usually download and install all the needed packages to make your module working.
A piece of the setup's output before setup.py finished would help us help you greatly.
Python for Windows [Nt - 7] is compiled with either cygwin or mingw, thus you not only need the python environment, but also said compiler, and python headers. If you want a more point and click install, then there's this professor at this university who maintains a good and up to date repository of scientific python modules, that depend on native extensions ( among which numpy, scipy, matplotlib).
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Manuals to setup mingw and python :
https://docs.python.org/2/using/windows.html
MingW can be downloaded from here:
http://www.mingw.org/
Best option for installing natgrid is from conda
conda install -c jochym natgrid=0.2
I have two installations of Python 2.7.2 -- from MacPorts and Enthought -- on my Mac. I use the Enthought Python as the primary one; however, the MacPorts distribution has several additional packages like pymacs, rope etc., which I would like to make available to the Enthought Python. (I'm actually trying to use Emacs w/ Enthought Python, but also make use of the MacPorts-installed Rope, Pymacs for code completion in Emacs).
Is there a clean way to make the MacPorts packages available to the Enthought Python without breaking anything?
It's risky trying to combine the two distributions, as you are likely to get conflicts (especially for C-extensions linked to slightly different versions of shared libraries). This is a common cause of problems with EPD:
https://support.enthought.com/entries/22094157-OS-X-Conflict-with-installed-packages-in-earlier-Python-installation
The recommended way to install new packages in EPD is with the enpkg tool. You can find out more about enpkg with enpkg --help or in this article:
https://support.enthought.com/entries/22415022-Using-enpkg-to-update-EPD-packages
If your package isn't available through enpkg (in your case it looks like rope is while pymacs is not, assuming you have an appropriate subscription), EPD is a very standard python distribution, and you can install packages in it through normal means such as pip or by grabbing the source and running python setup.py install. See:
https://support.enthought.com/entries/22914233-Using-non-EPD-package-installers-such-as-pip
It would be cleaner to install the additional packages once more for the Enthought Python. Trying to reuse packages from another installation seems neither clean nor safe to me.
This is a long post, so I'm putting a short summary with the question at the top.
Lion has been out long enough that I can finally install most of the Python libraries etc. I need using binary installs. I'm stuck when it comes to libsndfile. What is the best way to install libsndfile, and if it relates, the rest of this stuff?
Read on if you need more details...
I'm working on a program that uses the following, developing under OSX 10.7.3 initially and need to be able to build cross-platform on WinXp and Win7 as well:
Python 2.7.2
Numpy 1.6.1
SciPy 0.10.1
matplotlib 1.1.0
SciPy.scikits.samplerate
SciPy.scikits.audiolab
PortMidi
pyinstaller
I have all of these installed on my OSX dev machine, and everything works under the debugger. When I try to build with pyinstaller I run into trouble because my installs are a historical hodgepodge of binary installs, builds from source, easy_install, pip, and HomeBrew. With a couple files pulled from a useless MacPorts install. Some of libraries were installed when I was running Lion beta, when it was tricky to get some things working under Lion.
My thinking is that Lion has been out long enough that it should be possible to do a cleaner installation, and that should simplify things going forward, especially with pyinstaller. I created a fresh Lion VM and did the following:
1. Installed Python 2.7.2 Mac OS X 64-bit/32-bit x86-64/i386 from binaries.
2. Installed numpy-1.6.1-py2.7-python.org-macosx10.6 from binaries.
3. Installed scipy-0.10.1-py2.7-python.org-macosx10.6 from binaries.
4. Installed matplotlib-1.1.0-py2.7-python.org-macosx10.6 from binaries.
5. Installed Xcode 4.3.1 and downloaded command tools
6. Installed libsamplerate-0.1.8 from source; required by scikits.samplerate
So far everything has gone fine, although I'm not sure about i386 vs x86_64 architectures for libsamplerate; I may need to go back and install it once for each architecture and then create a universal binary.
Next up is libsndfile, which is required by scikits.audiolab. This one is trouble, as I find an ever-expanding web of dependencies:
libiconv
ncurses
expat
gettext
glib
pkg-config
libFlac
libogg
libvorgis
Gettext was a pain, as the stpncpy error I was getting has been posted about several places, but finding the patches that actually fix the problem was a bit tedious.
Even after apparently building all of the dependencies I've listed, libsndfile still won't build without errors and I'm stuck.
Looking at the amount of time I've spent failing to get libsndfile working, I'm starting to question the basic approach. I seem to not have the ability to figure out all the errors and make the appropriate changes in finite time.
I find myself heading back down the package manager path... easy_install to pip and HomeBrew; but some things only MacPorts seems to handle, but overall MacPorts screws with Python in ways I can't accept, and pyinstaller hates MacPorts. If I do this, I may or may not get things working again, but even if I do, I'm concerned that I won't know which pieces were actually required or be able to maintain the dev environment over time.
I was trying to install matplotlib in Mac OSX Lion. Tried to used the binary that is in the sourcefourge site, but I got this error: "matplotlib requires System Python 2.7 to install".
I went to the Terminal and typed python --version and its check the requirements.
After this I tried to used the pip, and while doing so é got the following error:
"src/_image.cpp:908: error: invalid use of incomplete type ‘struct png_info_def’"
Can you give me clues in how to install it?
Many thanks.
EDIT: I found a way, without having to install a new version of python:
http://the.taoofmac.com/space/blog/2011/07/24/2222
This is because of a change in the API for libpng v1.5 (which is included with Mac OSX Lion). The changes has already been pushed upstream, so you will need to compile from the upstream repository until the next release.
You can follow the instructions on http://jholewinski.wordpress.com/2011/07/21/installing-matplotlib-on-os-x-10-7-with-homebrew/
I followed this page's instructions. I got stuck at
pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev
Then I did:
git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py build
python setup.py install
Checked my installation by typing in terminal:
python
import matplotlib
print matplotlib.__version__
print matplotlib.__file__
I got version 0.10.0 dev (as of this writing) and path /usr/local/Cellar/...
You can try with an "official" python distribution, apple might have tweaked the supplied one. You can find the 2.7 here: http://www.python.org/download/
You might have to re-install numpy as well afterwords: http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/
I would suggest to install scipy as well
Let me know if it works ;)
I would recommend using macports, it should take care of dependencies and would be indepedent of the system python version.
EDIT: Just a few clarifications, taking into account comments to this answer.
Why use macports (or another installer)? Because they take care of dependencies, provide functionality to uninstall and switch between versions (I've used the latter successfully for gcc and python). And because the default installation location is not the system executable location. Overriding the system python can break applications that rely on it (this is certainly true in many Linux distributions, maybe less so on mac OS X).
When is it particularly useful? When you want to install on top of a version of python that is different to system python, and when you have non-python extensions (C, C++, Fortran...).
What's the down side? As #Trond has mentioned in the comments, it is good if you're OK with default compilations of packages. You don't have a handle over configuration or compiler flags as you would if you built from source.
A good alternative to macports is fink, which seems to give you more control (build from source). I am not sure it is completely ready for mac OS X Lion yet.
I know it will take a lot more time, but I would reccomend installing python, numpy, and matplotlib from source to ensure that you have consistency in your system. From the error it could look like you have a problem with libPNG support. I have a written a "How to install python dev tools on Mac OSX" that you may find useful. It contains directions for how to install python, numpy, matplotlib and all necessary dependencies. I understand you are working with Python 2.7 and the directions I am listing is for Python 2.6.5, but it would be the same approach. Hope you get it to work.
You could just install the Python 2.6 version of Matplotlib, assuming that Python2.6 is included with Lion (py2.5 & 2.6 are included with Mac OS 10.6 "Snow Leopard" - try typing python2.6 to find out if that version is installed.).
On MacPorts you do this via something like:
sudo port install py26-matplotlib
where py26-... (or py25-..., py27-... etc.) indicates which python version it is meant for. (check the Pallet/ports list to get the correct package name, in case I guessed wrong)
I've been trying to connect opencv and python in both Ubuntu and Windows XP. I've failed on both.
I've read many webpages and threads about "how to install" it but none has worked (the worst part is that they all say kind of the same).
Steps (windows xp):
Installed Python 2.7 by default (works perfectly)
Installed PIL and cx_Freeze (may they
create a conflict? I don't think so
:s)
Installed Opencv 2.2 by default
(OpenCV-2.2.0-win32-vs2010.exe) and
it isn't recognized inside a py nor
as import opencv.cv nor using the
cookbook way, import cv (I skipped
the visual studio steps since I'll
use it with python)
Checked path (it's ok, it has the
Opencv2.2\bin thing)
Rechecked webpages and stuff
Steps (ubuntu):
Had python working
sudo apt-get install, cmake, make,
sudo make install, etcetc (from the
tutorials)
same thing... module not recognized
Please can you help?
Update:
I managed to install it and have it recognized by the system (I used http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and it worked perfectly after that).
The problem now is that it crashes when I try to use CaptureFromFile. Someone else has reported it 3 days ago so now I wait.
I'll check the other wrappers, maybe one of them will work.
For windows see my web page: http://www.modernmind.org/wiki/OpenCV
For Ubuntu you should just need to apt-get install python-dev then generate the make files with Cmake, build it and then make install. In order to build the python bindings you need to have the python header files on your system and you probably don't. When you run configure in Cmake make sure that you don't see any messages at the top about PYTHON_INCLUDE not being defined.
To access a library it needs a Python library installed in the Python version you are using. From what you write above it seems to me that you install OpenCV in general, but that you don't specifically install the Python library. This is why it doesn't work.
I'm not sure how to install the Python wrappers, and the OpenCV documentation is a bit sparse on that info. But if you did build them (and that needs to be turned on explicitly, says the docs) they seem to end up in opencv/release/lib .
Look at "Testing Python wrappers" on http://opencv.willowgarage.com/wiki/InstallGuide
If there is still no luck, there is a bunch of alternative Python wrappers available: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
Maybe they are better documented.