I had problems installing psycopg2 in a virtualenv.
I tried different things explained there: http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/
The last thing I tried is this...
I created a virtualenv with -p python2.5 --no-site-packages
I installed libpq-dev: apt-get install libpq-dev
In the virtualenv, I did this: easy_install -i http://downloads.egenix.com/python/index/ucs4/ egenix-mx-base
Then when I tried pip install psycopg2==2.0.7, I got this error:
Installing collected packages: psycopg2
Running setup.py install for psycopg2
building 'psycopg2._psycopg' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.2 (dt dec ext pq3)" -DPG_VERSION_HEX=0x080404 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/usr/include/python2.5 -I. -I/usr/include/postgresql -I/usr/include/postgresql/8.4/server -c psycopg/psycopgmodule.c -o build/temp.linux-i686-2.5/psycopg/psycopgmodule.o -Wdeclaration-after-statement
psycopg/psycopgmodule.c:27:20: error: Python.h: No such file or directory
In file included from psycopg/psycopgmodule.c:31:
./psycopg/python.h:31:26: error: structmember.h: No such file or directory
./psycopg/python.h:34:4: error: #error "psycopg requires Python >= 2.4"
In file included from psycopg/psycopgmodule.c:32:
Does anyone have any idea how to solve that?
Thanks.
From python-list:
Diez:
Install the python-dev-package. It
contains the Python.h file, which the
above error message pretty clearly
says. Usually, it's a good idea to
search package descriptions of
debian/ubuntu packages for missing
header files to know what to install.
Pascal:
It's already installed; at least for
Python 2.6, nor sure it's correct for
Python 2.5. python2.5-dev is not available but
python-old-doctools seems to replace it.
Diez:
It is 100% not correct for
python2.5. As the error message shows
- it's missing.
If it's not available somewhere, you
should consider building python
yourself, if you have to use 2.5.
Alex:
Ubuntu 10.04 doesn't have a full
Python 2.5 packaged, as evidenced by
the lack of python2.5-dev. You need to
use Python 2.6 or if you absolutely
must use Python 2.5 build it from
source, try a Debian package or switch
distro. python-old-doctools does not
replace python- dev, it looks like it
was bodged to keep some latex tools
working.
Pascal: I finally created a virtualenv
with Python 2.6 and everything went fine
(with the latest version of psycopg2).
Related
I'm trying to install the latest version of mply (3.5.0) on xubuntu (ubuntu 17.10):
download the .tar.gz
Unzipped it
python setup.py build. Here I get the error displayed below.
also tried directly python setup.py install. same error.
tried installing gsl library by downloading the latest version, and following all the steps in https://coral.ise.lehigh.edu/jild13/2016/07/11/hello/. I have it installed in /home/gsl
still the same error
tried various other installations (sudo apt-get install libgsl0ldbl, sudo apt-get install libgs123, sudo apt-get install libgsl0-dev). Nothing works.
tried copying the folder /home/gsl/include/gsl inside the mply-3.5.0/mply/gsl folder . this slightly changes something, because now I get fatal error: gsl/gsl_sf_result.h: No such file or directory (So it finds gsl_sf.h, but not gsl_sf_result.h (both these files are present inside the /gsl/include/gsl folder).
tried with
python setup.py build_ext --include-dirs=/home/gls/include/gls
still nothing
tried to copy the /home/gsl/include/gsl folder inside my /usr/local/include:
cp -R /home/gsl/include/gsl /usr/local/include/gsl
still nothing.
Help!
Error message:
gcc -pthread -B /home/lorenzo/anaconda3/compiler_compat
-Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -I/home/lorenzo/anaconda3/include/python3.6m
-I/home/lorenzo/anaconda3/lib/python3.6/site-packages/numpy/core/include
-I/home/lorenzo/anaconda3/include/python3.6m -c mlpy/gsl/gsl.c
-o build/temp.linux-x86_64-3.6/mlpy/gsl/gsl.o
mlpy/gsl/gsl.c:223:10: fatal error: gsl/gsl_sf.h: No such file or directory
#include "gsl/gsl_sf.h"
SOLVED by re-installing gsl library using conda:
conda install gsl
I am trying to install PyCrypto on OS X 10.11.3 (El Capitan). I am using Python 3.5.1. I downloaded the gzip file from https://pypi.python.org/pypi/pycrypto and decompressed it. Then I ran python setup.py build like the instructions said and it appeared to do something, then it produced this output:
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/MD2.c -o build/temp.macosx-10.6-intel-2.7/src/MD2.o
src/MD2.c:30:10: fatal error: 'string.h' file not found
#include <string.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
I tried python3 setup.py build and got some very similar output:
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -fno-common -dynamic -fwrapv -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c src/MD2.c -o build/temp.macosx-10.6-intel-3.5/src/MD2.o
src/MD2.c:30:10: fatal error: 'string.h' file not found
#include <string.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
I tried Googling to figure out what to do, but I couldn't find anything useful. How can I install PyCrypto?
EDIT: I also tried several other things like pip install pycrypto and sudo pip3 install pycrypto and they didn't work. #l'L'l helped me get it to work by doing several strange, complex things that I never would have though have myself. They are summarized in the answer below.
Overview:
The manual build you're trying looks like it might be failing because it's referencing the OS X 10.6 SDK, which you likely don't have, and is outdated for the most part. Also, SDKs are now stored in a completely different location than when the 10.6 SDK was in it's prime.
New SDKs location:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
Old SDKs location:
/Developer/SDKs/
Non-existent / outdated SDK:
Since it appears that when trying to build PyCrypto it's referencing the MacOSX10.6.sdk there are several things to consider:
Why does it reference an outdated SDK
Where is the SDK it's referencing set
What should be done to correct the issue
Unless we audit the source code carefully we might not know exactly where the incorrect flags are set, but we can do our best to work with the information we have. From the error we can see that there are several instances where the 10.6 SDK's name pops up:
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -arch x86_64 -fwrapv -Wall -Wstrict-prototypes -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/Library
Building from source:
/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/MD2.c -o build/temp.macosx-10.6-intel-2.7/src/MD2.o
src/MD2.c:30:10: fatal error: 'string.h' file not found
#include <string.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
Analyzing this we can see that the PyCrypto's MD2.c file is trying to be built using the flag -isysroot /Developer/SDKs/MacOSX10.6.sdk. It might be worth trying pip instead:
Installing with pip:
...
fatal error: 'string.h' file not found #include <string.h>
...
Same error; we should probably find out if the <string.h> header even exists on the system — Let's make a quick test C application to find out:
Testing the C headers:
$ echo "#include <string.h>
#include <stdio.h>
int main() { printf(\"TEST\n\"); return 0; }" > t.c
$ clang t.c -o t
$ ./t
TEST
It's apparent the header does exist because the test worked fine. This tells us that the problem is more likely related directly to the 10.6 SDK (which doesn't seem to exist on the system).
Symlinking (non-existing) 10.6 SDK to 10.11 SDK:
Since we haven't determined where the SDK is actually getting set we'll go ahead and try to create symlinks so that any reference of the old 10.6 SDK links to the latest SDK (10.11 at this time):
$ cd /Developer/SDKs
$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk MacOSX10.6.sdk
We can verify the symlink by issuing the following command:
$ ls -lat
total 8
drwxr-xr-x 3 root wheel 102 Feb 21 15:54 .
lrwxr-xr-x 1 root wheel 99 Feb 21 15:54 MacOSX10.6.sdk -> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
drwxr-xr-x 3 root wheel 102 Feb 21 15:52 ..
Now that we've successfully created the symlink let's try installing PyCrypto with pip once more:
$ sudo pip install pycrypto
Collecting pycrypto
Downloading pycrypto-2.6.1.tar.gz (446kB)
100% |████████████████████████████████| 446kB 1.2GB/s
Installing collected packages: pycrypto
Running setup.py install for pycrypto ... done
Successfully installed pycrypto-2.6.1
No errors! It looks like our problem is solved! Well, almost...
We still need to figure out what is responsible for setting the wrong (10.6) SDK during builds. Let's use the xcrun tool to see what the defaults are set at:
$ xcrun --show-sdk-version
10.11
The system default SDK is set to 10.11, so it must be get set incorrectly to 10.6 by Python, PyCrypto, or some other anomaly we might not have considered.
UPDATE:
After doing some recon it was discovered that Python 3 appears to be built with the OS X 10.6 SDK. In addition it's also setting the SDK to 10.6 and setting the (outdated) path in numerous places throughout the Python_Framework. There are so many references I won't bother listing them all, although here's an example:
Python_Framework Folder/Versions/3.5/lib/python3.5/config-3.5m/Makefile:79:CONFIGURE_CFLAGS= -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk
I can only assume the developers were trying to be as backward compatible as possible, however, it's unfortunately breaking forward compatibility in the process.
Notes:
Installing Python packages with pip can make life much easier in a lot of ways (package management, updating, uninstalling, etc.). For example installing PyCrypto should just be a matter of issuing the command:
$ sudo pip install pycrypto
If you have multiple Python's you can use the version number to install for that Python accordingly:
$ sudo pip3.5 install pycrypto
↳ https://pip.pypa.io/en/stable/installing/
I had what might be a related issue on OSX El Capitan when I would run pip install pycrypto. I was seeing RuntimeError: autoconf error. All I had to do was run sudo xcodebuild -license and type agree after reviewing the licence agreement. Afterward I was able to use pip to install pycrypto.
I build libyaml and install it into a local area:
yaml-0.1.5 $ ./configure --prefix=/usr/local/sqlminus
yaml-0.1.5 $ make install
yaml-0.1.5 $ ls -l /usr/local/sqlminus/include/yaml.h
-rw-r--r--# 1 mh admin 54225 Jan 5 09:05 /usr/local/sqlminus/include/yaml.h
But when I build PyYAML, it cannot find yaml.h.
PyYAML-3.11 $ /usr/local/sqlminus/bin/python setup.py build
checking if libyaml is compilable
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -I/usr/local/sqlminus/include/python2.7
-c build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c
-o build/temp.macosx-10.4-x86_64-2.7/check_libyaml.o
build/temp.macosx-10.4-x86_64-2.7/check_libyaml.c:2:10:
fatal error: 'yaml.h'
file not found
#include <yaml.h>
^
1 error generated.
How can I tell PyYAML where I've installed libyaml?
(update) Based on dotslash's comment below, editing setup.cfg and adding these two lines made everything work smoothly.
include_dirs=/usr/local/sqlminus/include
library_dirs=/usr/local/sqlminus/lib
(end update)
I think you should install dependencies.
If you are using Ubuntu or Debian based system, you could search by this
apt-cache search libyaml
Then you may find there are some packages related.
I would suggest you try to install this: apt-get install libyaml-dev -y
If you are using Mac OS, you could change the source in file check_libyaml.c, tell it what the absolute path of yaml.h is.
Or just specify the path while compiling
python setup.py config --with-includepath=/path/to/your/install/of/python/includes/
Then go compiling.
More info can be found here.
Hope this be helpful.
Based on dotslash's comment, editing setup.cfg and adding these two lines made everything work smoothly:
include_dirs=/usr/local/sqlminus/include
library_dirs=/usr/local/sqlminus/lib
Having looked at other similar threads, I still can't get pycrypto running.
I'm trying to get it working on my Ubuntu laptop - but I couldn't manage it on my Windows PC either.
I downloaded pycrypto-2.6, extracted it, and ran
python setup.py build
but then this happened
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Hash._MD2' extension
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 - fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c -o build/temp.linux-i686-?2.7/src/MD2.o
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Would appreciate any help.
You need to install the Python development files. I believe this will do it:
sudo apt-get install python-dev
On Ubuntu, I needed some other packages for it to succeed:
apt-get install autoconf g++ python2.7-dev
pip install pycrypto
On Ubuntu and if you use Python 3.x you will need:
sudo apt-get install gcc python3-dev
you probably already have gcc but just in case if you are trying this command from Dockerfile with base image python:3.6.4-slim-jessie then you will also need gcc.
August 2021
For python 3.8 users run
sudo apt-get install python3.8-dev
and try to install pycrypto again
pip install pycrypto
Here is what I would like to do.
Use web2py with MySQL.
To do that, I need to use source web2py rather than web2py.app
To use web2py, I need Python 2.5
I am having trouble building and installing Python 2.5
I downloaded Python-2.5.6.tgz from Python release page.
Now, I did
./configure
and then
make
Then, I get the following error.
gcc -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp
-mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
cc1: error: unrecognized command line option
"-Wno-long-double" make: * [Modules/python.o] Error 1
Can anybody help me how to get rid of this error and install Python 2.5?
Here is gcc I am using
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build
2336.9.00)
Your help would be greatly appreciated.
Thanks.
web2py works fine with Lion's stock Python 2.7. Unless you have a compelling reason to use 2.5, stick with 2.7.
I have web2py on my iMac OSX Lion using the web2py app and MySQL. I haven't run into any reason why you can't use the app with MySQL.
To install Python on OS X, try using the Universal Binaries provided on python.org (documented at http://docs.python.org/2/using/mac.html).
See http://www.python.org/ftp/python/2.5.4/python-2.5.4-macosx.dmg for the most recent Universal Binary for Python 2.5.