[Tutor] Help with python in MAC OS 10.6

Cameron Simpson cs at zip.com.au
Fri Feb 27 23:58:42 CET 2015


On 27Feb2015 02:16, Barbara Heliodora G. Rodrigues <barbara_hgr at yahoo.com.dmarc.invalid.br> wrote:
>I'd like to ask for help with an issue I have with python. My MAC is with OS 10-6.8, darwin kernel, 64 bits. For some reason I updated macports and it automatically updated python to 2.7 with a 32 bits library, and it is giving me lots of trouble. I can't install any new software that uses python, and recently I tried to use some plot (matplotlib) routines that were working fine before, simply didn't work, the window with the plot didn't open.Is there a way to force macports to install a 64bits version of python?

Since I use MacPorts and Alan doesn't I'll chip in...

First up, you're talking about the MacPorts pythn (in /opt/local) not the 
system Python (in /usr).

This page:

  http://stackoverflow.com/questions/2111283/how-to-build-64-bit-python-on-os-x-10-6-only-64-bit-no-universal-nonsense

seems to offer useful advice on getting MacPorts to install your preferred 
variant on Python.

Next, re this:
>I downloaded and installed the 3.4 and 3.1 myself, but still the computer only sees the version macports installed.

You need to clarify what this statement means, probably with examples of how 
you are invoking your python programs, and the output of "which python".

Your Mac should (now) have multiple Pythons installed:

  /usr/bin/python
    Supplied with MacOSX, the system Python. Probably 64-bit python. As the 
    cited web page above says, run:

      file /usr/bin/python

    to see what architecture it is. You can do that for any of the other 
    executables too to check how they were built.

  /opt/local/bin/python
    The MacPorts python (python 2 by default). It should like you need to 
    reinstall this with the right "variants" settings to get it to be 64-bit.

  Your personally built Pythons.

Regarding the last, please outline what options you used to build these. It is 
very important to build/install with a suitable --prefix Configure option to 
put them in the right place: not a specific place, but a place _not_ 
conflicting with the OSX or MacPorts pythons, for example 
/usr/local/python-2.7.7 (adjust to suit).

It is normal to add some symlinks in /usr/local/bin for "python", "python2" etc 
pointing at your preferred executables.

Next, _how_ are you installing extra packages like matplotlib etc?

I would advocate using MacPorts to install these if available; that leaves the 
arrangements in the hands of MacPorts and keeps things simple for you.

Otherwise, I would next suggest learning to use virtualenv to make a specific 
python "environment" for you work. This is easier than it sounds. The 
virtualenv command prepares a direct of your choice (eg $HOME/venv-2.7.7, to 
invent a name) which contains "python" and "pip" executables in the "bin" 
subdirectory which are crafted to automatically install and use packages 
entirely within the virtualenv directory, avoiding conflicts with other systems 
like OSX or MacPorts. This is great for experimentation of maintaining special 
setups of your own.

You can base the virtualenv of any of the installed Pythons (OSX, MacPorts, 
whatever), to get the installed libraries for free.

Please respond with further information and we can proceed from there.

Cheers,
Cameron Simpson <cs at zip.com.au>

To have no errors
Would be life without meaning
No struggle, no joy
- Haiku Error Messages http://www.salonmagazine.com/21st/chal/1998/02/10chal2.html


More information about the Tutor mailing list