python3 configure script error - could not find pthreads - python

I am trying to compile python 3.7.7 on mac os Big Sur.
Downloaded the source code from python.org
running the configure script exits on error
configure: error: could not find pthreads on your system
cmake version 3.19.0
gcc version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Related

Python is 32-bit, chosen compiler is 64-bit [duplicate]

I'm trying to compile pybind11 on a Windows machine that has VisualStudio 2015 installed. I also have python 3.5.3 64bit installed, and cmake 2.8.12. I get the error:
CMake Error at tools/FindPythonLibsNew.cmake:122 (message):
Python config failure: Python is 64-bit, chosen compiler is 32-bit
Call Stack (most recent call first):
tools/pybind11Tools.cmake:16 (find_package)
CMakeLists.txt:28 (include)
I did not "choose" the compiler to be 32-bit, and looking at the CMakeLists.txt, I did not find any place to specify which compiler to run.
So how to I tell pybind11/cmake to compile for 64 bit?
You should specify the 64-bit VS compiler like so:
cmake "/path/to/src/" -G"Visual Studio 14 2015 Win64"
Otherwise it selects the 32-bit by default.
If you are using the Ninja generator and you have this error make sure you run the VS Dev command prompt in 64-bit mode:
VsDevCmd.bat arch=amd64 && cmake <options> ...
You can either do :
cmake .. -G"Visual Studio 14 2015 Win64"
cmake --build . --config Release --target check
or based on this quote from the Compiling the test cases for windows section here:
If all tests fail, make sure that the Python binary and the testcases
are compiled for the same processor type and bitness (i.e. either i386
or x86_64). You can specify x86_64 as the target architecture for the
generated Visual Studio project using cmake -A x64 ..
You can do :
cmake -A x64 ..
cmake --build . --config Release --target check

Install anaconda on ARM Cortex-A9 platform

Base situation:
Platform: ARM Cortex-A9 (32-bit processor)
OS: Ubuntu Mate 16.04.4
gcc version: gcc (Ubuntu/Linaro 5.4.0-6ubuntu1-16.04.4) 5.4.0 201606609
python version: 2.7.12
Question:
I want to install anaconda on ARM Cortex-A9 platform. However, when I execute:
$./Anaconda2-5.0.1-Linux-x86.sh
It return an error:
/root/anaconda2/pkgs/python-2.7.14-h41cc02d_21/bin/python:1: /root/anaconda2/pkgs/python-2.7.14-h41cc02d_21/bin/python:Syntax error:word unexpected (expecting ")")
How I can fit this problem? How I can install anaconda on ARM platform?
Tks.
I think you need to run the command like this:
$ bash Anaconda2-5.0.1-Linux-x86.sh
because it's actually a bash script :)

Which GCC version do I have on my OS X Sierra

When I type gcc -v, I get :
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../gcc-4.9-20141029/configure --enable-languages=c++,fortran
Thread model: posix
gcc version 4.9.2 20141029 (prerelease) (GCC)
So my gcc version is 4.9.2
However, when I try to install gcc again by typing : brew tap homebrew/versions; brew install gcc --without-multilib
I get :
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/core, homebrew/science, homebrew/versions).
==> New Formulae
git-quick-stats homebrew/science/med-file ktmpl
==> Updated Formulae
aha homebrew/science/bowtie mpd
akka homebrew/science/cdo mysql-cluster
arangodb homebrew/science/matplotlib no-more-secrets
buku homebrew/science/packmol nvm
bullet homebrew/science/paraview protobuf-swift
casperjs homebrew/science/pymol qca
certigo imagemagick ✔ ringojs
chicken imagemagick#6 rust
cjdns jenkins skinny
coffeescript jigdo sqldiff
compcert jump sqlite-analyzer
crystal-lang kobalt svtplay-dl
dbhash libhdhomerun swiftgen
digdag libphonenumber vim
direnv libsigsegv wakatime-cli
elixirscript mapserver wolfssl
embulk mecab-jumandic yank
geoserver mkvtoolnix yaz
gitlab-ci-multi-runner mosquitto
==> Deleted Formulae
bip homebrew/versions/openssl101 probatron4j
edelta lcab rtpbreak
esound malaga
Updating Homebrew...
Warning: gcc-6.3.0_1 already installed
This output says at the end that I have gcc 6.3 .
Am I working with gcc 4.9.2 or gcc 6.3 ?
P.S : If you are interested in why I executed the brew tap & brew install commands, it is because I am trying to install xgboost in python. In the github repo of xgboost, they're advising to run the above commands before installation to get the latest g++ compiler.
To address your question "Am I working with gcc 4.9.2 or gcc 6.3"
You are still working with gcc 4.9.2.
How can you make gcc-6 your default compiler? See below:
sudo ln -s <path-to>/gcc-6 <path-to>/gcc
Reload and verify
Now exit the terminal session and open a new terminal (so the links update) and type gcc -v and see if the version is now the latest.
Other related tools
NOTICE: You may also wish to update c++ -> c++-6, g++ -> g++-6, and cpp -> cpp-6 in a similar fashion, just repeat the above step for each in turn, ALWAYS BACKUP in case something goes wrong so you can undo everything if necessary.
NOTE:
If you get a "Operation not permitted" warning and you are using El Capitan or newer version of Mac OS X please see this question/answer on how to disable the security feature that is preventing you from making changes to /usr/bin directory:
https://superuser.com/questions/933019/sudo-cant-create-file-in-usr-bin-in-el-capitan

Homebrewed python gtk import results in segmentation fault

I am trying to get my brewed version of python to work with the brewed gtk. However, I get this error. I can't find the problem that is causing this issue. This error occurs after pygtk is installed.
$ python
Python 2.7.5
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtk-2.0/gio/__init__.py:23: Warning: g_str_has_prefix: assertion `str != NULL' failed
from _gio import *
Segmentation fault: 11
The versions gtk and pygtk packages installed are gtk+-2.24.20 and pygtk: stable 2.24.0.
My list of brew installed packages is:
atk gdk-pixbuf jpeg pango pygobject
cairo gettext libffi pcre pygtk
cmake glib libpng pixman python
fontconfig gtk+ libtiff pkg-config readline
freetype harfbuzz nginx postgresql sqlite
gdbm icu4c ossp-uuid py2cairo xz
The same problem for me when I am trying to launch zim note app. OS X has own python which linked to /usr/bin/python and brew link own compiled python in /usr/local/bin/python.
With Apple's python I can launch zim app but It crashes on double click (two-fingers tap).
With Brew's python I cant launch Zim at all. Shell show me the same error:
python /Users/md760/my_apps/zim-0.62/zim.py
/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gtk-2.0/gio/__init__.py:23: Warning: g_str_has_prefix: assertion `str != NULL' failed
from _gio import *
Segmentation fault: 11
So at least creating ticket to brew githab is good idea.
Seems that this error can appear when you were installed few gtk (pygtk) libs. For example one from brew repo and another from any dmg or like that.
So I can advise you to remove one of them, for example non-brew version:
# rm -rf /opt/gtk
And then try to import gtk in python

Can't load mysqlclient.18.dylib into python on Mac OS Lion

I want to get MySQL working with the system Python 2.7 in Mac OS X Lion.
I know there are a lot of questions very similar to this out there, and in fact my symptom is identical to mysql-python installation problems (on mac os x lion). However, that answer doesn't seem to apply to my case.
My Mac is a current MacBook Pro running the 64-bit kernel:
% uname -a
Darwin Leos-MacBook-Pro.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
The stock python on Lion is a fat binary:
% file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 2 architectures
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture i386): Mach-O executable i386
I had used Migration Assistant so my system had an old installation of MySQL on it. I used the instructions at How to remove installation of MySQL on Mac OS X to remove the old MySQL installation.
MySQL 64-bit 5.5.19 was installed from the .dmg on the MySQL site. As usual, this placed the client library in /usr/local/mysql/lib. The client library appears to be exactly what we want:
% file /usr/local/mysql/lib/libmysqlclient.18.dylib
/usr/local/mysql/lib/libmysqlclient.18.dylib: Mach-O 64-bit dynamically linked shared library x86_64
However, that shared library can't be loaded into python (I'm using the arch command to make absolutely sure I'm running the 64-bit image although the result is the same with or without that):
% arch -x86_64 python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import cdll
>>> cdll.LoadLibrary("/usr/local/mysql/lib/libmysqlclient.18.dylib")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/mysql/lib/libmysqlclient.18.dylib, 6): no suitable image found. Did find:
/usr/local/mysql/lib//libmysqlclient.18.dylib: mach-o, but wrong architecture
/usr/local/mysql/lib/libmysqlclient.18.dylib: mach-o, but wrong architecture
I can reproduce this problem many other ways, notably by using the standard import MySQLdb; I'm showing the ctypes way of reproducing the bug specifically because I was trying to figure out whether the problem was in mysql-python or in the MySQL client library. From the above, it seems to be the client library. However, I'm baffled as to why the loader thinks the client library is the wrong architecture.
In trying to see whether it's some dependent library that's the problem, I checked the dependencies in libmysqlclient.18.dylib:
% otool -L /usr/local/mysql/lib/libmysqlclient.18.dylib
/usr/local/mysql/lib/libmysqlclient.18.dylib:
libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.1)
And of course /usr/lib/libSystemB.dylib is a fat binary as expected:
% file /usr/lib/libSystem.B.dylib
/usr/lib/libSystem.B.dylib: Mach-O universal binary with 2 architectures
/usr/lib/libSystem.B.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libSystem.B.dylib (for architecture i386): Mach-O dynamically linked shared library i386
So... Python is 64-bit, the mysqlclient library is 64-bit, and the dependent libraries are all 64-bit... Any guesses as to why the loader is refusing the import the library would be very welcome.
Just for the belt-and-suspenders checking that everything's 64-bit-y:
% python -c 'import platform; print platform.platform()'
Darwin-11.2.0-x86_64-i386-64bit
% ls -l /usr/local/mysql
lrwxr-xr-x 1 root wheel 27 Dec 10 16:52 /usr/local/mysql# -> mysql-5.5.19-osx10.6-x86_64
At this point, since I need to actually get some work done, I'm going to try switching to pymysql. This is mostly for use with Django, for which there's a convenient way to swap pymysql in documented at the bottom of this thread.
P.S. I understand macports and can't use it on this system.
Chances are you have set the default execution mode of the Apple-supplied Python to 32-bits, either by using defaults or by setting the VERSIONER_PYTHON_PREFER_32_BIT environment variable; see man python for details. In OS X 10.6 and 10.7 /usr/bin/python is an Apple-supplied wrapper program that determines which Python to run and in which mode. Using arch to execute /usr/bin/python will not influence the interpreter. For example:
$ unset VERSIONER_PYTHON_PREFER_32_BIT
$ arch -x86_64 /usr/bin/python -c "import sys;print(sys.maxsize)"
9223372036854775807
$ export VERSIONER_PYTHON_PREFER_32_BIT=yes
$ arch -x86_64 /usr/bin/python -c "import sys;print(sys.maxsize)"
2147483647
#
# But avoiding the wrapper program ....
#
$ arch -x86_64 /usr/bin/python2.7 -c "import sys;print(sys.maxsize)"
9223372036854775807
$ arch -i386 /usr/bin/python2.7 -c "import sys;print(sys.maxsize)"
2147483647

Categories

Resources