Search code examples
pythonmacospython-3.xterminalmacports

Error using python with terminal after installing python 3.6 using macports


I use macports to install packages on my laptop. I have used it to set up and install a python environment (version 2.7). Upon installing python27 and using macports to set python the command to point to the python27 I am able, in the terminal to type:

:~ python

which correctly opens a python environment in my terminal session, where I can execute python commands.

When I follow the same process using macports to install a python 3.6 environment and type the command:

:~ python3

The environment loads correctly, however if I try to run any command in this environment, such as:

>>> print('Hello')

I get the following error:

>>> print('Hello')
Python(24202,0x7fffc0d003c0) malloc: *** error for object 0x10a78f110: 
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

This only occurs when I use the terminal python environment. For all intents and purposes, the install runs fine and I am able to run python 3 programs on my system and things like IPython work fine. This is a specific problem for when I enter the python3 terminal environment after installing it using macports.

I would like to know, what causes this to happen and is there a way I can fix it?

I have tried commands like:

port diagnose

and removing the port, all related ports and reinstalling but I am presented with the exact same error. Does anyone else experience this or have a resolution for it?


Solution

  • Please check out this link #48807, it is a known issue and below lines are quoted from the thread:

    Just installed python36 and the install recommend py36-readline and had malloc crashes along the lines of pointer being freed was not allocated python.

    Found this thread. Uninstalled py36-readline and installed python36 +readline, which seems to have fixed this.