I am adding python 2.7.13 as an altinstall by installing the source code to my RHEL4 box with
wget --no-check-certificate https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
tar -xvzf Python2.7.13.tar.xz
cd Python2.7.13
./configure --with-ensurepip=install
make
make test
make altinstall
so that I do not overwrite the default python that is required for other use. Python 2.7.13 would successfully install but was missing several essential modules for the project I am working on.
Originally the _ssl and _haslib modules would error in this section.
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _sqlite3 _tkinter
bsddb185 dbm dl
gdbm imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
I installed openssl and ensured that they were in the default location that python was looking for them, so now I have the necessary bits but then it ends with this message instead
Failed to build these modules:
_hashlib _ssl
Below is the entire output of the python2.7 setup.py build from the unzipped python package. I have been scouring google and anywhere I can find but I have been unsuccessful in anything so far
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers
building '_ssl' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/ssl/include -I. -IInclude -I./Include -I/usr/local/include -I/usr/local/include/python2.7 -c /Python/Modules/_ssl.c -o build/temp.linux-x86_64-2.7/Python/Modules/_ssl.o
/Python/Modules/_ssl.c:57: warning: ignoring #pragma GCC diagnostic
/Python/Modules/_ssl.c: In function ‘_setup_ssl_threads’:
/Python/Modules/_ssl.c:4012: warning: comparison is always false due to limited range of data type
gcc -pthread -shared build/temp.linux-x86_64-2.7/Python/Modules/_ssl.o -L/usr/local/ssl/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.7/_ssl.so
/usr/bin/ld: /usr/local/ssl/lib/libssl.a(s3_meth.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libssl.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
building '_hashlib' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/ssl/include -I. -IInclude -I./Include -I/usr/local/include -I/usr/local/include/python2.7 -c /Python/Modules/_hashopenssl.c -o build/temp.linux-x86_64-2.7/Python/Modules/_hashopenssl.o
gcc -pthread -shared build/temp.linux-x86_64-2.7/Python/Modules/_hashopenssl.o -L/usr/local/ssl/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.7/_hashlib.so
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(o_names.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libcrypto.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _sqlite3 _tkinter
bsddb185 dbm dl
gdbm imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_hashlib _ssl
running build_scripts
When I attempt to use pip that is installed with my python 2.7.13 I get an SSL error so I have been installing all my packages and other modules from the source like cx_Oracle and CherryPy.
pip2.7 install cffi
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting cffi
Could not fetch URL https://pypi.python.org/simple/cffi/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement cffi (from versions: )
No matching distribution found for cffi
I also tried to add the ssl module manually with
wget --no-check-certificate https://pypi.python.org/packages/83/21/f469c9923235f8c36d5fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz#md5=fb12d335d56f3c8c7c1fefc1c06c4bfb
tar -xvzf ssl-1.16.tar.gz
cd ssl-1.16
python2.7 setup.py build
But I get an error that it should not be used with python past 2.6
Traceback (most recent call last):
File "setup.py", line 12, in <module>
+ "or earlier.")
ValueError: This extension should not be used with Python 2.6 or later (already built in), and has not been tested with Python 2.3.4 or earlier.
EDIT
I was looking around for solutions and after combing over the outputs of the setup.py build and found someone with a similar-ish problem that seems to be related to openssl here
so I rebuilt my openssl with
./config enable-shared
make
make test
make install
and now I get a slightly different error about the ssl module, am I just screwing up my environment more and more?
python2.7 setup.py build
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers
building '_ssl' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/ssl/include -I. -IInclude -I./Include -I/usr/local/include -I/usr/local/include/python2.7 -c /Python/Modules/_ssl.c -o build/temp.linux-x86_64-2.7/Python/Modules/_ssl.o
/Python/Modules/_ssl.c:57: warning: ignoring #pragma GCC diagnostic
/Python/Modules/_ssl.c: In function ‘_setup_ssl_threads’:
/Python/Modules/_ssl.c:4012: warning: comparison is always false due to limited range of data type
gcc -pthread -shared build/temp.linux-x86_64-2.7/Python/Modules/_ssl.o -L/usr/local/ssl/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.7/_ssl.so
*** WARNING: renaming "_ssl" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory
building '_hashlib' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/ssl/include -I. -IInclude -I./Include -I/usr/local/include -I/usr/local/include/python2.7 -c /Python/Modules/_hashopenssl.c -o build/temp.linux-x86_64-2.7/Python/Modules/_hashopenssl.o
gcc -pthread -shared build/temp.linux-x86_64-2.7/Python/Modules/_hashopenssl.o -L/usr/local/ssl/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.7/_hashlib.so
*** WARNING: renaming "_hashlib" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _sqlite3 _tkinter
bsddb185 dbm dl
gdbm imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_hashlib _ssl
running build_scripts
The new warning message in the output *** WARNING: renaming "_ssl" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory indicates that the file does not exist but I see it in /usr/local/ssl/lib/ as libssl.so.1.0.0 and can find it with a search
find / -name libssl.so.1.0.0
/usr/local/ssl/lib/libssl.so.1.0.0
/tmp/openssl-1.0.2l/libssl.so.1.0.0
Well, I don't know whether to feel stupid and this is just a common thing I completely overlooked doing since I am fairly new to linux CLI. But, I was able to resolve my build error for the _hashlib and _ssl modules with a couple simple steps in https://stackoverflow.com/a/28460293/8222554 amo's response.
I first attempted the ldconfig but that did not resolve my issue so I simply looked at what was in my LD_LIBRARY_PATH with
echo $LD_LIBRARY_PATH
and then got back these locations which did not include where the libssl.so.1.0.0 file was located
/usr/lib/oracle/11.2/client64/lib:/usr/lib/oracle/11.2/client/lib
Then I followed the steps I had done previously when installing the Oracle instant client and cx_Oracle module which were easily laid out on on this blog post: https://ubuntugeeknerd.blogspot.com/2013/08/how-to-install-oxoracle-in-rhel-64-bit.html
Those steps I used for the ssl module were as follow
export LD_LIBRARY_PATH=/usr/local/ssl/lib/:$LD_LIBRARY_PATH >> ~/.bashrc
echo $LD_LIBRARY_PATH
/usr/local/ssl/lib/:/usr/lib/oracle/11.2/client64/lib:/usr/lib/oracle/11.2/client/lib
After this I did python2.7 setup.py clean followed by python2.7 setup.py build and last python2.7 setup.py install. The output didn't return any failed to build besides the ones which I did not have the necessary bits for (and was not looking to build anyways).
I can verify the ssl module is there now when opening up python and importing the module successfully
Python 2.7.13 (default, Jun 26 2017, 15:21:33)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
Hopefully this will be handy to someone who is running into a similar issue
Related
I'm trying to install mpi4py on my Ubuntu 18.04 instance. I have python3.6.5 installed.
First I try sudo apt-get build-dep python-mpi4py and I get:
Reading package lists... Done E: You must put some 'source' URIs in
your sources.list
I then try to install simply with pip install mpi4py. I get a long error message and I include some of the most important parts below:
checking for library 'lmpe' ...
/home/ubuntu/anaconda3/envs/tensorflow_p36/bin/mpicc -pthread -B /home/ubuntu/anaconda3/envs/tensorflow_p36/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -c _configtest.c -o _configtest.o
--------------------------------------------------------------------------
The Open MPI wrapper compiler was unable to find the specified compiler
x86_64-conda_cos6-linux-gnu-cc in your PATH.
Note that this compiler was either specified at configure time or in
one of several possible environment variables.
--------------------------------------------------------------------------
failure.
This failure occurs for most libraries. I include just one of the many, and
warning: build_clib: command '/home/ubuntu/anaconda3/envs/tensorflow_p36/bin/mpicc' failed with exit status 1
warning: build_clib: building optional library "vt-mpi" failed
checking for library 'vt-hyb' ...
/home/ubuntu/anaconda3/envs/tensorflow_p36/bin/mpicc -pthread -B /home/ubuntu/anaconda3/envs/tensorflow_p36/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -c _configtest.c -o _configtest.o
--------------------------------------------------------------------------
The Open MPI wrapper compiler was unable to find the specified compiler
x86_64-conda_cos6-linux-gnu-cc in your PATH.
Note that this compiler was either specified at configure time or in
one of several possible environment variables.
Running which mpcc gives:
(tensorflow_p36) ubuntu#ip-172-31-35-200:~$ which mpicc
/home/ubuntu/anaconda3/envs/tensorflow_p36/bin/mpicc
How can I add the specified compiler x86_64-conda_cos6-linux-gnu-cc to my PATH in order to resolve this error?
Simply run:
conda install -c anaconda mpi4py as shown here.
Also, a helpful comment by Lidandro Dalcin:
I guess you are missing the mpich-mpicc package, this one is a
metapackage that depends in the right compiler. Why are you installing
mpi4py with pip? Maybe all you need is to conda install mpi4py
(available in the conda-forge channel) ?
I want to wrap a test project containing C++ and OpenMP code with Cython, and build it with distutils via a setup.py file. The content of my file looks like this:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext
modules = [Extension("Interface",
["Interface.pyx", "Parallel.cpp"],
language = "c++",
extra_compile_args=["-fopenmp"],
extra_link_args=["-fopenmp"])]
for e in modules:
e.cython_directives = {"embedsignature" : True}
setup(name="Interface",
cmdclass={"build_ext": build_ext},
ext_modules=modules)
The -fopenmp flag is used with gcc to compile and link against OpenMP. However, if I just invoke
cls ~/workspace/CythonOpenMP/src $ python3 setup.py build
this flag is not recognized, because the compiler is clang:
running build
running build_ext
skipping 'Interface.cpp' Cython extension (up-to-date)
building 'Interface' extension
cc -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c Interface.cpp -o build/temp.macosx-10.8-x86_64-3.3/Interface.o -fopenmp
clang: warning: argument unused during compilation: '-fopenmp'
cc -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c Parallel.cpp -o build/temp.macosx-10.8-x86_64-3.3/Parallel.o -fopenmp
clang: warning: argument unused during compilation: '-fopenmp'
Parallel.cpp:24:10: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma omp parallel for
^
1 warning generated.
c++ -bundle -undefined dynamic_lookup -L/usr/local/lib -L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-3.3/Interface.o build/temp.macosx-10.8-x86_64-3.3/Parallel.o -o build/lib.macosx-10.8-x86_64-3.3/Interface.so -fopenmp
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'c++' failed with exit status 1
I've unsucessfully tried to specify gcc:
cls ~/workspace/CythonOpenMP/src $ python3 setup.py build --compiler=g++-4.7
running build
running build_ext
error: don't know how to compile C/C++ code on platform 'posix' with 'g++-4.7' compiler
How can I tell distutils to use gcc?
Try setting the "CC" environment variable from inside the setup.py with os.environ.
I just took a look at the distutils source, and the --compiler option expects "unix", "msvc", "cygwin", "mingw32", "bcpp", or "emx". It checks the compiler name you want by checking the CC environment variable. Try calling build like this:
CC=gcc python setup.py build
You don't need to set CXX, it doesn't check for that.
Just in case some others are facing the same problem under Windows (where CC environment variable wouldn't have any effect) :
Create file "C:\Python27\Lib\distutils\distutils.cfg" and write this inside :
Code :
[build]
compiler = mingw32
Remove all instances of "-mno-cygwin" gcc option from file "C:\Python27\Lib\distutils\cygwinccompiler.py" :
This :
self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
compiler_so='gcc -mno-cygwin -mdll -O -Wall',
compiler_cxx='g++ -mno-cygwin -O -Wall',
linker_exe='gcc -mno-cygwin',
linker_so='%s -mno-cygwin %s %s'
% (self.linker_dll, shared_option,
entry_point))
Becomes this :
self.set_executables(compiler='gcc -O -Wall',
compiler_so='gcc -mdll -O -Wall',
compiler_cxx='g++ -O -Wall',
linker_exe='gcc',
linker_so='%s %s %s'
% (self.linker_dll, shared_option,
entry_point))
The second point can be necessary in case you are using a recent version of gcc, where the deprecated option -mno-cygwin has been removed.
Hope this will help even if it is not directly related to the OP real needs (but still related to the question's title...)
According to this wiki, Python versions after 3.4 do not support MinGW anymore.
CPython 3.7 for Windows is compiled with MSC v.1916. When I try to use above-mentioned method with distutils.cfg, I then get an error from distutils: Unknown MS Compiler Version 1916. Looks like it has a hardcoded table of msvcr libraries in its cygwincompiler.py file (which is also responsible for MinGW), and last version known to that file is 1600 from VS2010 / MSVC 10.0.
Try this:
http://mail.python.org/pipermail/distutils-sig/2002-August/002944.html
In short, it appears that you should try: python setup.py build --compiler=g++ first.
On linux while using distutils.ccompiler do
os.environ('CC')='gcc' and then call distutils.sysconfig.customize_compiler(compiler)
It will do the job.
I'm trying to install PIL on OSX 10.6.8 using pip in virtualenv, but it fails with gcc returning 1 exit status.
here's what i get:
$ pip install PIL
Downloading/unpacking PIL
Running setup.py egg_info for package PIL
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
Installing collected packages: PIL
Running setup.py install for PIL
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -I/opt/local/include/freetype2 -IlibImaging -I/opt/local/include -I/Users/DataGreed/workspaces/vitrualenv/project/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _imaging.c -o build/temp.macosx-10.6-universal-2.6/_imaging.o
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/as/ppc/as or /usr/bin/../local/libexec/as/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/as/x86_64/as for architecture x86_64
/usr/bin/../libexec/as/i386/as for architecture i386
/usr/bin/../libexec/as/arm/as for architecture arm
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
_imaging.c:3281: fatal error: error writing to -: Broken pipe
compilation terminated.
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
lipo: can't open input file: /var/folders/sO/sODPLYP7Goy5NCFskrL1dE+++TM/-Tmp-//ccds0vgZ.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
Complete output from command /Users/DataGreed/workspaces/vitrualenv/project/bin/python -c "import setuptools;__file__='/Users/DataGreed/workspaces/vitrualenv/project/build/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/sO/sODPLYP7Goy5NCFskrL1dE+++TM/-Tmp-/pip-BNAuaC-record/install-record.txt --single-version-externally-managed --install-headers /Users/DataGreed/workspaces/vitrualenv/project/bin/../include/site/python2.6:
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
running install
running build
running build_py
running build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -I/opt/local/include/freetype2 -IlibImaging -I/opt/local/include -I/Users/DataGreed/workspaces/vitrualenv/project/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _imaging.c -o build/temp.macosx-10.6-universal-2.6/_imaging.o
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/as/ppc/as or /usr/bin/../local/libexec/as/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/as/x86_64/as for architecture x86_64
/usr/bin/../libexec/as/i386/as for architecture i386
/usr/bin/../libexec/as/arm/as for architecture arm
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
_imaging.c:3281: fatal error: error writing to -: Broken pipe
compilation terminated.
_imaging.c:3017: warning: initialization from incompatible pointer type
_imaging.c:3077: warning: initialization from incompatible pointer type
lipo: can't open input file: /var/folders/sO/sODPLYP7Goy5NCFskrL1dE+++TM/-Tmp-//ccds0vgZ.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
UPD: on the other computer with the same osx version it installs flawlessly :-/
UPD2: there is a more strange thing actually. I have PIL already installed via pip outside virtualenv. But I cannot install it in virtualenv only.
UPD3: i dunno if it can help, but when I load virtualenv wrapper scripts, i got this:
/Library/Python/2.6/site-packages/stevedore/extension.py:4: UserWarning: Module
pkg_resources was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.pyc, but /Library/Python/2.6/site-packages is being added to sys.path
import pkg_resources
/Library/Python/2.6/site-packages/stevedore/extension.py:4: UserWarning: Module site was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site.pyc, but /Library/Python/2.6/site-packages is being added to sys.path
import pkg_resources
When I use workon, i get the same warnings.
Have you tried Pillow? (pip install pillow):
http://pypi.python.org/pypi/Pillow/
It makes life with PIL much easier. I was able to install PIL via Pillow on OSX with virtualenv and virtualenvwrapper.
Mine installs fine into a virtualenv on 10.6.8 but...
mine is being built with gcc-4.0 , while yours is being built with 4.2 ; and 4.2 should be the default.
so i don't actually know why mine is being built with gcc-4.0 , but it does work fine.
$ which gcc
/usr/bin/gcc
$ ls -alh /usr/bin/gcc
lrwxr-xr-x 1 root wheel 7B Jan 3 2012 /usr/bin/gcc -> gcc-4.2
I have XCode installed and also FreeTDS. I tried to connect to my SQL Server and it works perfect.
Now I have to develop an aplication on python that works with this SQL Server and I´m trying to install pymsql, but I got this error when I launche sudo python setup.py command:
==> sudo python setup.py install
running install
running bdist_egg
running egg_info
writing pymssql.egg-info/PKG-INFO
writing top-level names to pymssql.egg-info/top_level.txt
writing dependency_links to pymssql.egg-info/dependency_links.txt
reading manifest file 'pymssql.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymssql.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-intel/egg
running install_lib
running build_ext
skipping '_mssql.c' Cython extension (up-to-date)
building '_mssql' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/sw/include -Ifreetds/nix_64/include -I/opt/local/include -I/opt/local/include/freetds -I/opt/local/freetds/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mssql.c -o build/temp.macosx-10.7-intel-2.7/_mssql.o -DMSDBLIB
_mssql.c: In function ‘__pyx_f_6_mssql_15MSSQLConnection_convert_python_value’:
_mssql.c:7322: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c: In function ‘__pyx_f_6_mssql_15MSSQLConnection_get_result’:
_mssql.c:9554: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c:9566: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c: In function ‘__pyx_pf_6_mssql_20MSSQLStoredProcedure_2bind’:
_mssql.c:11146: warning: implicit conversion shortens 64-bit value into a 32-bit value
llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/_mssql.o -L/sw/lib -Lfreetds/nix_64/lib -L/opt/local/lib -L/opt/local/lib/freetds -L/opt/local/freetds/lib -lsybdb -lrt -o build/lib.macosx-10.7-intel-2.7/_mssql.so
ld: warning: directory not found for option '-L/sw/lib'
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/opt/local/lib/freetds'
ld: warning: directory not found for option '-L/opt/local/freetds/lib'
ld: library not found for -lrt
collect2: ld returned 1 exit status
ld: warning: directory not found for option '-L/sw/lib'
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/opt/local/lib/freetds'
ld: warning: directory not found for option '-L/opt/local/freetds/lib'
ld: library not found for -lrt
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//cc6eQsIN.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1
Any help or clue?
Unfortunately, pymssql's setup.py (as of version pymssql-2.0.0b1-dev-20111019) needs a bit of help to work properly on OSX Lion. The current setup.py tries to compile/link against some pre-built Linux FreeTDS libraries, and also tries to link against librt, which doesn't exist on OSX. Additionally, it only explicitly looks for FreeTDS libraries from Fink or MacPorts, so if you've installed Homebrew (if you use if) or FreeTDS itself in a non-standard location, it may not be located by compiler/linker.
I created a repaired version of setup.py here. It worked well enough for me with the Homebrew build of FreeTDS using the standard locations (/usr/local/{lib, include}), but as always YMMV. You may need to adjust setup.py further if you've installed FreeTDS in a different location. You can generally ignore the warnings from the linker about missing directories that may not exist on your system:
ld: warning: directory not found for option '-L/usr/local/lib/freetds'
One other note: You will probably have built FreeTDS for a single architecture, likely x86_64. By default, pymssl will be a multi-architecture build (assuming you're using the system Python 2.7.1), so even with a patched setup.py you will see a linker warning something like:
ld: warning: ignoring file /usr/local/lib/libsybdb.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
That warning just indicates that the FreeTDS libraries only have single architecture version to link against. You can avoid the warning by using ARCHFLAGS to make a x86_64-only build:
ARCHFLAGS="-arch x86_64" python setup.py install
Or, try this fork, it installs without issues:
https://github.com/blackbass1988/pymssql-macos-lion
To install on OS X Mavericks, you need
OS X Command Line Tools
FreeTDS
brew install freetds
Cython
pip install cython
and then finally you can install the pymssql-macoslion
pip install git+git://github.com/blackbass1988/pymssql-macos-lion.git#master
Just incase anyone is reading this the following worked for me:
brew install freetds
sudo pip install pymssql
IF I use --no-site-packages option while creating a virtualenv and try to install MySQL-python afterwards I get :
error: command 'gcc' failed with exit status 1
Here are the steps I followed:
easy_install-2.7 --install-dir ~/src/lib/ virtualenv==dev
~/src/lib/virtualenv --no-site-packages ENV
.../ENV/bin/pip-2.7 install MySQL-python
I also tried downloading mySQL-python and install using
.../ENV/bin/python setup.py build
I get the same error wither way.
I assume I am missing the gcc from this virtualenv but how do I get it installed in this virtualenv while still using --no-site-packages option.
thanks
EDIT: as per below comments here is the whole error output.
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
building '_mysql' extension
gcc -m32 -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/opt/lampp/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv
In file included from /opt/lampp/include/python2.7/Python.h:58,
from pymemcompat.h:10,
from _mysql.c:29:
/opt/lampp/include/python2.7/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
In file included from /usr/include/mysql/my_config.h:11,
from _mysql.c:36:
/usr/include/mysql/my_config_x86_64.h:1032:1: warning: "SIZEOF_LONG" redefined
In file included from /opt/lampp/include/python2.7/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/opt/lampp/include/python2.7/pyconfig.h:989:1: warning: this is the location of the previous definition
error: command 'gcc' failed with exit status 1
you need the mysql-devel package. to install, you need to specify the actual package name -
sudo apt-get install libmysql++-dev
Have you tried using the sudo command. I am guessing you are having permission issues than issue with anything else here. Usually an install throws up this error as it is trying to access directories with root permission which you don't own.