How to install psycopg2-2.6 with python2.6 - python

my linux server: 2.6.18 RHEL5
gcc version: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
installed rpm packages:
python26-2.6.5-4.el5
python26-devel-2.6.5-4.el5
postgresql-devel-8.1.23-1
postgresql-libs-8.1.23-1
postgresql-devel-8.1.23-1
postgresql-8.1.23-1
when I run "python2.6 setup.py install", the error message is:
gcc -pthread -shared build/temp.linux-x86_64-2.6/psycopg/psycopgmodule.o build/temp.linux-x86_64-2.6/psycopg/green.o build/temp.linux-x86_64-2.6/psycopg/pqpath.o build/temp.linux-x86_64-2.6/psycopg/utils.o build/temp.linux-x86_64-2.6/psycopg/bytes_format.o build/temp.linux-x86_64-2.6/psycopg/connection_int.o build/temp.linux-x86_64-2.6/psycopg/connection_type.o build/temp.linux-x86_64-2.6/psycopg/cursor_int.o build/temp.linux-x86_64-2.6/psycopg/cursor_type.o build/temp.linux-x86_64-2.6/psycopg/diagnostics_type.o build/temp.linux-x86_64-2.6/psycopg/error_type.o build/temp.linux-x86_64-2.6/psycopg/lobject_int.o build/temp.linux-x86_64-2.6/psycopg/lobject_type.o build/temp.linux-x86_64-2.6/psycopg/notify_type.o build/temp.linux-x86_64-2.6/psycopg/xid_type.o build/temp.linux-x86_64-2.6/psycopg/adapter_asis.o build/temp.linux-x86_64-2.6/psycopg/adapter_binary.o build/temp.linux-x86_64-2.6/psycopg/adapter_datetime.o build/temp.linux-x86_64-2.6/psycopg/adapter_list.o build/temp.linux-x86_64-2.6/psycopg/adapter_pboolean.o build/temp.linux-x86_64-2.6/psycopg/adapter_pdecimal.o build/temp.linux-x86_64-2.6/psycopg/adapter_pint.o build/temp.linux-x86_64-2.6/psycopg/adapter_pfloat.o build/temp.linux-x86_64-2.6/psycopg/adapter_qstring.o build/temp.linux-x86_64-2.6/psycopg/microprotocols.o build/temp.linux-x86_64-2.6/psycopg/microprotocols_proto.o build/temp.linux-x86_64-2.6/psycopg/typecast.o -L. -L/usr/lib64 -lpython2.6 -lpq -o build/lib.linux-x86_64-2.6/psycopg2/_psycopg.so
/usr/bin/ld: build/temp.linux-x86_64-2.6/psycopg/psycopgmodule.o: relocation R_X86_64_PC32 against `lobjectType' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld return 1
error: command 'gcc' failed with exit status 1
when I use "gcc -fPIC", the result is still the same.

I know this was asked a long time ago, but I recently came across the same problem described (though on a CentOS system instead of Red Hat).
I am not sure if this will help, but my problem is the version of libpq (installed with Postgres) is "too old". The solution that worked for me was to install version 2.5 of psycopg2. This version is good enough for my needs.
I found the idea here:
https://github.com/psycopg/psycopg2/issues/305
I used version 2.5, but perhaps a slightly newer version would work as well. I found the source code here:
http://initd.org/psycopg/tarballs/PSYCOPG-2-5/

Related

Installing an older version of python

I am currently using a mac version 11.6.1 with Big Sur on it. I have the latest version of python (3.9) on it, however I need to use 3.6 for a project at work. I attempted to use pyenv to install this version but ran into a number of issues with pyenv. So, I next went to https://www.python.org/downloads/release/python-3615/ and downloaded this version. In my terminal I ran the following commands.
$ cd Downloads
$ cd python-3.6.15
$ ./configure
$ make
Here I ran into this error.
./Modules/getpath.c:528:49: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Wincompatible-pointer-types]
else if(0 == _NSGetExecutablePath(execpath, &nsexeclength) && execpath[0] == SEP) {
^~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach-o/dyld.h:98:54: note: passing argument to parameter 'bufsize' here
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize) __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
^
1 warning generated.
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o
./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = sendfile(in, out, offset, &sbytes, &sf, flags);
^
./Modules/posixmodule.c:10432:5: warning: code will never be executed [-Wunreachable-code]
Py_FatalError("abort() called from Python code didn't abort!");
^~~~~~~~~~~~~
1 warning and 1 error generated.
make: *** [Modules/posixmodule.o] Error 1
I am banging my head against the wall here with the errors from pyenv and now this. My attempt here was to run a virtual environment with virtualenv and point it at the 3.6 version of python, however, as you can see I can't seem to install python correctly. Any assistance here would be appreciated.
Since I was asked about the error with pyenv I'll include that here too.
BUILD FAILED (OS X 11.6.1 using python-build 2.2.0-5-g54889eb8)
Inspect or clean up the working tree at /var/folders/77/93y4tp5x557ff0h_3f76bh5c0000gn/T/python-build.20211104075648.30324
Results logged to /var/folders/77/93y4tp5x557ff0h_3f76bh5c0000gn/T/python-build.20211104075648.30324.log
Last 10 log lines:
checking for --with-cxx-main=<compiler>... no
checking for clang++... no
configure:
By default, distutils will build C++ extension modules with "clang++".
If this is not intended, then set CXX on the configure command line.
checking for the platform triplet based on compiler characteristics... darwin
configure: error: internal configure error for the platform triplet, please file a bug report
make: *** No targets specified and no makefile found. Stop.
with penv try this:
# get latest pyenv version
brew unlink pyenv
brew install pyenv --HEAD
CFLAGS=-Wno-implicit-function-declaration pyenv install 3.6.15

Can't install C-based modules like lxml and Cython on Python 3.6 on Raspberry Pi

I built Python 3.6 from source and am trying to install lxml. Trying to install it from pip gives the following error:
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/local/include/python3.6m -c src/lxml/etree.c -o build/temp.linux-armv6l-3.6/src/lxml/etree.o -w
src/lxml/etree.c:91:20: fatal error: Python.h: No such file or directory
compilation terminated.
Compile failed: command 'gcc' failed with exit status 1
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitln68cjsn.c -o tmp/xmlXPathInitln68cjsn.o
cc tmp/xmlXPathInitln68cjsn.o -L/usr/lib -lxml2 -o a.out
error: command 'gcc' failed with exit status 1
The same error is raised if I try to install Cython to compile lxml from source. I installed libxml2-dev and libxslt1-dev, but python3.6-dev, which is apparently also required, is not found in Raspbian repository. I added the following line to /etc/apt/sources.list:
deb http://ftp.de.debian.org/debian sid main
But when trying to install it afterwards, I receive the following error:
The following packages have unmet dependencies:
libdbus-1-3 : Breaks: dbus (< 1.9.16-1~) but 1.6.8-1+deb7u1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
In fact, this error is raised on any package that is found in Debian repository that is not in Raspbian one. What can I do about this?
Since you installed Python from source, you should have the header files already. Should also use header files for the version that you built as opposed to the version in the package manager.
Either
Add the source code directory to includes used by GCC (gcc -I<dir>) or
Install the from source package in a system directory that is automatically included like /usr/include or /usr/local/include
The second option is probably easiest and should be possible from the standard configure/make scripts.

relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC

I got this error message after run it on Centos 7 (512MB).
sudo make pycaffe
or
sudo make distribute
Error message
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [python/caffe/_caffe.so] Error 1
I had the same problem with trying to install dlib. The solution was to build Python with the --enable-shared flag. When using pyenv it can be done like this:
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --force 2.7.11
I had recently encountered a similar error with another software package.
Try passing CFLAGS="-fPIC" or CXXFLAGS="-fPIC" while configuring or building. That worked for me.
You might also want to go through this page on -fPIC errors:

How to build Python with Clang on Mac OS X Mavericks

How can I build Python with Clang on Mac OS X? Mavericks already comes with Python 2.7 installed. The reason I'm asking is because I am having issues trying to install PyLucene and it's possibly because Python was compiled with something other than Clang, while JCC as part of PyLucene needs to be compiled with Clang.
i see your problem now. when building jcc,
clang++ -Wl,-x -dynamiclib -undefined dynamic_lookup build/temp.macosx-10.9-x86_64-2.7/jcc/sources/jcc.o build/temp.macosx-10.9-x86_64-2.7/jcc/sources/JCCEnv.o -o build/lib.macosx-10.9-x86_64-2.7/libjcc.dylib -L/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib -ljava -L/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/server -ljvm -Wl,-rpath -Wl,/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib -Wl,-rpath -Wl,/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/server -Wl,-S -install_name #rpath/libjcc.dylib -current_version 2.21 -compatibility_version 2.21
ld: internal error: atom not found in symbolIndex(__ZN7JNIEnv_13CallIntMethodEP8_jobjectP10_jmethodIDz) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang++' failed with exit status 1
actually this is a known issue, and the solution is here
-x link flag causing link errors on Mac OSX 10.9 (bug?)
just run the above clang++ command without the "-x" in the same directory. and then run the "python setup.py build" again...

cx_Freeze building error

Im trying to install cx_Freeze for Python 3.3. However, when compiling the source I get this error
gcc -pthread build/temp.linux-i686-3.3/source/bases/Console.o -L/usr/local/lib/python3.3/config-3.3m -lpython3.3 -o build/lib.linux-i686-3.3/cx_Freeze/bases/Console -Xlinker -export-dynamic -lpthread -ldl -lutil -lm -s
/usr/bin/ld: cannot find -lpython3.3
collect2: error: ld returned 1 exit status
Since I'm a newbie I couldn't really figure out what's missing so I've tried installing libpython3.3-dev and python3.3-dev, but this doesn't solve the problem. I don't know if this is wheather a Python or gcc problem. What am I missing?
create link and it will be ok!
sudo ln /usr/local/lib/libpython3.3m.a /usr/local/lib/libpython3.3.a

Categories

Resources