Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter1 Helloworld for Mac and Python installed with homebrew #5

Open
thilaire opened this issue Apr 6, 2016 · 1 comment
Open

Comments

@thilaire
Copy link

thilaire commented Apr 6, 2016

Hi
I was trying your 1st example (Chapter 1, Helloworld), and I get the following message

Python 2.7.11 (default, Jan 22 2016, 16:30:50)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import helloworld
Fatal Python error: PyThreadState_Get: no current thread
fish: 'python' terminated by signal SIGABRT (Abort)

After some googling, I've discovered that the error comes from the fact that I am using, on my mac, several Python versions (one from Apple, and the others installed with the homebrew system, as described here for example)

The command otool -L helloworld.so returns

helloworld.so (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.17.0)

indicating that the helloworld.so was linked with the Python 2.7.5 (the original apple version), that is not the active version (Python 2.7.11, installed with homebrew).

So, I changed a little bit the Makefile to

all:
    cython -2 -o helloworld.c helloworld.pyx
    gcc -g -O2 -fpic -c helloworld.c -o helloworld.o `python-config --cflags`
    gcc -g -O2 -shared -o helloworld.so helloworld.o `python-config --ldflags`

(--ldflagsinstead of --libs) and everything is fine, now.

@philberty
Copy link
Owner

Nice find! You can submit a pull request if you like and i will merge in :).

Thanks.

On 6 April 2016 at 22:32, thilaire [email protected] wrote:

Hi
I was trying your 1st example (Chapter 1, Helloworld), and I get the
following message

Python 2.7.11 (default, Jan 22 2016, 16:30:50)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import helloworld
Fatal Python error: PyThreadState_Get: no current thread
fish: 'python' terminated by signal SIGABRT (Abort)

After some googling, I've discovered that the error comes from the fact
that I am using, on my mac, several Python versions (one from Apple, and
the others installed with the homebrew system, as described here
http://docs.python-guide.org/en/latest/starting/install/osx/ for
example)

The command otool -L helloworld.so returns

helloworld.so (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.17.0)

indicating that the helloworld.so was linked with the Python 2.7.5 (the
original apple version), that is not the active version (Python 2.7.11,
installed with homebrew).

So, I changed a little bit the Makefile to

all:
cython -2 -o helloworld.c helloworld.pyx
gcc -g -O2 -fpic -c helloworld.c -o helloworld.o python-config --cflags
gcc -g -O2 -shared -o helloworld.so helloworld.o python-config --ldflags

(--ldflagsinstead of --libs) and everything is fine, now.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants