Discussion:
error psycopg in Django/MacOSX
Daniel França
2010-07-13 03:15:04 UTC
Permalink
Hi,
I recently migrated from Linux to Mac OS X, and I'm trying to get my django
project working.
I'm getting problems trying to install psycopg2
I installed that, both when I try to run my django server I get the
following error:
*
*
*gresql_psycopg2/base.py", line 24, in <module>*
* raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)*
*django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module:
dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so,
2): Symbol not found: _PQbackendPID*
* Referenced from:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
*
* Expected in: flat namespace*
* in
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
*


I don't know why it's happening, mayble incorrect version?
I'm using Python 2.7 and Postgresql8.4 and Psycopg 2.2.1

Thanks

Best Regards,
Daniel França
Jan Urbański
2010-07-13 08:39:02 UTC
Permalink
Post by Daniel França
Hi,
I recently migrated from Linux to Mac OS X, and I'm trying to get my django
project working.
I'm getting problems trying to install psycopg2
I installed that, both when I try to run my django server I get the
*
*
*gresql_psycopg2/base.py", line 24, in<module>*
* raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)*
dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so,
2): Symbol not found: _PQbackendPID*
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
*
* Expected in: flat namespace*
* in
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
*
I have seen this error reported several times on IRC and on this list.
It usually has something to do with either _psycopg.so, libpq.so or the
python interpreter being built with the incorrect architectures.

Try running:

file /path/to/libpq.so.X.X

file /path/to/_psycopg.so

python -c 'import pprint; from distutils import sysconfig;
pprint.pprint(sysconfig.parse_makefile(sysconfig.get_makefile_filename()))'

python -c 'import platform; print platform.architecture()'

python -c 'import platform; print platform.machine()'

python -c 'import platform; print platform.mac_ver()'

psql -c 'select version()'

And also googling for your error. I have seen reports of people solving
that problem by switching their system python into 32 bit mode, but then
again I have seen people for which it did not work.

Cheers,
Jan
Daniel França
2010-08-03 13:52:10 UTC
Permalink
ok, this error doesn't happen anymore, I installed python32bits
My website is running, but when I try to insert some data at the
database I get the error:
Can't adapt type <<timezone>>
I tried to use timezone as 'US/Eastern', 'America/Sao_Paulo'
but the problem remains.
Maybe it's because my postgresql is 64 bits? How do I know if it is?
can anyone help me?
Daniel-Francas-MacBook-Pro:psycopg2-2.2.1 danielfranca$ python -c 'import
pprint; from distutils import sysconfig;
pprint.pprint(sysconfig.parse_makefile(sysconfig.get_makefile_filename()))'
{'AR': 'ar',
 'ARFLAGS': 'rc',
 'ASDLGEN': '/Users/sysadmin/X/r27/Parser/asdl_c.py',
 'ASDLGEN_FILES': '/Users/sysadmin/X/r27/Parser/asdl.py
/Users/sysadmin/X/r27/Parser/asdl_c.py',
 'AST_ASDL': '/Users/sysadmin/X/r27/Parser/Python.asdl',
 'AST_C': '/Users/sysadmin/X/r27/Python/Python-ast.c',
 'AST_C_DIR': '/Users/sysadmin/X/r27/Python',
 'AST_H': '/Users/sysadmin/X/r27/Include/Python-ast.h',
 'AST_H_DIR': '/Users/sysadmin/X/r27/Include',
 'BASECFLAGS': '-fno-strict-aliasing -fno-common -dynamic',
 'BASEMODLIBS': '',
 'BINDIR': '/Library/Frameworks/Python.framework/Versions/2.7/bin',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 'BLDLIBRARY': '',
 'BLDSHARED': 'gcc-4.0 -arch i386 -arch ppc -arch x86_64 -isysroot / -g
-bundle -undefined dynamic_lookup',
 'BUILDEXE': '.exe',
 'BUILDPYTHON': 'python.exe',
 'CC': 'gcc-4.0',
 'CCSHARED': '',
 'CFLAGS': '-fno-strict-aliasing -fno-common -dynamic -arch i386 -arch ppc
-arch x86_64 -g -O2 -DNDEBUG -g -O3',
 'CFLAGSFORSHARED': '',
 'CONFIGFILES': 'configure configure.in acconfig.h pyconfig.h.in
Makefile.pre.in',
 'CONFIG_ARGS': "'-C' '--enable-framework' '--enable-universalsdk=/'
'--with-universal-archs=3-way' 'LDFLAGS=-g ' 'OPT=-g -O3 ' 'CC=gcc-4.0'",
'/Library/Frameworks/Python.framework/Versions/2.7/include',
'/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
':plat-darwin:plat-mac:plat-mac/lib-scriptpackages:lib-tk:lib-old',
 'CPPFLAGS': '-I. -IInclude -I/Users/sysadmin/X/r27/Include',
 'CXX': 'c++',
 'DESTDIRS': '/Library/Frameworks/Python.framework/Versions/2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 'DESTPATH': '',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 'DIRMODE': 755,
 'DIST': 'README ChangeLog configure configure.in acconfig.h pyconfig.h.in
Makefile.pre.in Include Lib Misc Demo Ext-dummy',
 'DISTDIRS': 'Include Lib Misc Demo Ext-dummy',
 'DISTFILES': 'README ChangeLog configure configure.in acconfig.h
pyconfig.h.in Makefile.pre.in',
 'DLINCLDIR': '.',
 'DLLLIBRARY': '',
 'DYNLOADFILE': 'dynload_shlib.o',
 'EXE': '',
 'EXEMODE': 755,
 'EXTRAMACHDEPPATH': ':plat-mac:plat-mac/lib-scriptpackages',
 'EXTRAPLATDIR': 'plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages
\tplat-mac/lib-scriptpackages/_builtinSuites
\tplat-mac/lib-scriptpackages/CodeWarrior
\tplat-mac/lib-scriptpackages/Explorer \tplat-mac/lib-scriptpackages/Finder
\tplat-mac/lib-scriptpackages/Netscape
\tplat-mac/lib-scriptpackages/StdSuites
\tplat-mac/lib-scriptpackages/SystemEvents
\tplat-mac/lib-scriptpackages/Terminal',
 'EXTRATESTOPTS': '',
 'EXTRA_CFLAGS': '',
 'FILEMODE': 644,
 'GLHACK': '-Dclear=__GLclear',
 'GNULD': 'no',
 'GRAMMAR_C': '/Users/sysadmin/X/r27/Python/graminit.c',
 'GRAMMAR_H': '/Users/sysadmin/X/r27/Include/graminit.h',
 'GRAMMAR_INPUT': '/Users/sysadmin/X/r27/Grammar/Grammar',
'/Library/Frameworks/Python.framework/Versions/2.7/include
/Library/Frameworks/Python.framework/Versions/2.7/include
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
 'INCLUDEDIR': '/Library/Frameworks/Python.framework/Versions/2.7/include',
'/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7',
 'INSTALL': '/usr/bin/install -c',
 'INSTALL_DATA': '/usr/bin/install -c -m 644',
 'INSTALL_PROGRAM': '/usr/bin/install -c',
 'INSTALL_SCRIPT': '/usr/bin/install -c',
 'INSTALL_SHARED': '/usr/bin/install -c -m 555',
 'INSTSONAME': 'Python.framework/Versions/2.7/Python',
 'LDCXXSHARED': 'c++ -arch i386 -arch ppc -arch x86_64 -isysroot / -g
-bundle -undefined dynamic_lookup',
 'LDFLAGS': '-arch i386 -arch ppc -arch x86_64 -isysroot / -g',
 'LDLAST': '',
 'LDLIBRARY': 'Python.framework/Versions/2.7/Python',
 'LDLIBRARYDIR': '',
 'LDSHARED': 'gcc-4.0 -arch i386 -arch ppc -arch x86_64 -isysroot / -g
-bundle -undefined dynamic_lookup',
 'LIBC': '',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 'LIBDIR': '/Library/Frameworks/Python.framework/Versions/2.7/lib',
 'LIBFFI_INCLUDEDIR': '',
 'LIBM': '',
 'LIBOBJDIR': 'Python/',
 'LIBOBJS': '',
 'LIBP': '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 'LIBPC': '/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config',
 'LIBRARY': 'libpython2.7.a',
 'LIBRARY_OBJS': 'Modules/getbuildinfo.o \t\tParser/acceler.o
\t\tParser/grammar1.o \t\tParser/listnode.o \t\tParser/node.o
\t\tParser/parser.o \t\tParser/parsetok.o \t\tParser/bitset.o
\t\tParser/metagrammar.o \t\tParser/firstsets.o \t\tParser/grammar.o
\t\tParser/pgen.o Parser/myreadline.o Parser/tokenizer.o
\t\tObjects/abstract.o \t\tObjects/boolobject.o \t\tObjects/bufferobject.o
\t\tObjects/bytes_methods.o \t\tObjects/bytearrayobject.o
\t\tObjects/capsule.o \t\tObjects/cellobject.o \t\tObjects/classobject.o
\t\tObjects/cobject.o \t\tObjects/codeobject.o \t\tObjects/complexobject.o
\t\tObjects/descrobject.o \t\tObjects/enumobject.o \t\tObjects/exceptions.o
\t\tObjects/genobject.o \t\tObjects/fileobject.o \t\tObjects/floatobject.o
\t\tObjects/frameobject.o \t\tObjects/funcobject.o \t\tObjects/intobject.o
\t\tObjects/iterobject.o \t\tObjects/listobject.o \t\tObjects/longobject.o
\t\tObjects/dictobject.o \t\tObjects/memoryobject.o
\t\tObjects/methodobject.o \t\tObjects/moduleobject.o \t\tObjects/object.o
\t\tObjects/obmalloc.o \t\tObjects/rangeobject.o \t\tObjects/setobject.o
\t\tObjects/sliceobject.o \t\tObjects/stringobject.o \t\tObjects/structseq.o
\t\tObjects/tupleobject.o \t\tObjects/typeobject.o
\t\tObjects/weakrefobject.o \t\tObjects/unicodeobject.o
Objects/unicodectype.o \t\tPython/_warnings.o \t\tPython/Python-ast.o
\t\tPython/asdl.o \t\tPython/ast.o \t\tPython/bltinmodule.o
\t\tPython/ceval.o \t\tPython/compile.o \t\tPython/codecs.o
\t\tPython/errors.o \t\tPython/frozen.o \t\tPython/frozenmain.o
\t\tPython/future.o \t\tPython/getargs.o \t\tPython/getcompiler.o
\t\tPython/getcopyright.o \t\tPython/getplatform.o \t\tPython/getversion.o
\t\tPython/graminit.o \t\tPython/import.o \t\tPython/importdl.o
\t\tPython/marshal.o \t\tPython/modsupport.o \t\tPython/mystrtoul.o
\t\tPython/mysnprintf.o \t\tPython/peephole.o \t\tPython/pyarena.o
\t\tPython/pyctype.o \t\tPython/pyfpe.o \t\tPython/pymath.o
\t\tPython/pystate.o \t\tPython/pythonrun.o \t\tPython/structmember.o
\t\tPython/symtable.o \t\tPython/sysmodule.o \t\tPython/traceback.o
\t\tPython/getopt.o \t\tPython/pystrcmp.o \t\tPython/pystrtod.o
\t\tPython/dtoa.o \t\tPython/formatter_unicode.o
\t\tPython/formatter_string.o \t\tPython/dynload_shlib.o \t\t
\t\tPython/mactoolboxglue.o \t\tPython/thread.o \t\tModules/config.o
\t\tModules/getpath.o \t\tModules/main.o \t\tModules/gcmodule.o \t\t
\t\tModules/threadmodule.o  Modules/signalmodule.o  Modules/posixmodule.o
 Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o
 Modules/_codecsmodule.o  Modules/zipimport.o  Modules/symtablemodule.o
 Modules/xxsubtype.o',
 'LIBS': '-ldl  -framework CoreFoundation',
 'LIBSUBDIRS': 'lib-tk lib-tk/test lib-tk/test/test_tkinter
lib-tk/test/test_ttk site-packages test test/data \t\ttest/decimaltestdata
test/xmltestdata \t\tencodings compiler hotshot \t\temail email/mime
email/test email/test/data \t\tjson json/tests \t\tsqlite3 sqlite3/test
\t\tlogging bsddb bsddb/test csv importlib wsgiref \t\tlib2to3 lib2to3/fixes
lib2to3/pgen2 lib2to3/tests \t\tlib2to3/tests/data lib2to3/tests/data/fixers
lib2to3/tests/data/fixers/myfixes \t\tctypes ctypes/test ctypes/macholib
idlelib idlelib/Icons \t\tdistutils distutils/command distutils/tests xml
xml/dom xml/etree xml/parsers xml/sax \t\tmultiprocessing
multiprocessing/dummy \t\tunittest unittest/test \t\tlib-old \t\tcurses
pydoc_data plat-darwin plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages
\tplat-mac/lib-scriptpackages/_builtinSuites
\tplat-mac/lib-scriptpackages/CodeWarrior
\tplat-mac/lib-scriptpackages/Explorer \tplat-mac/lib-scriptpackages/Finder
\tplat-mac/lib-scriptpackages/Netscape
\tplat-mac/lib-scriptpackages/StdSuites
\tplat-mac/lib-scriptpackages/SystemEvents
\tplat-mac/lib-scriptpackages/Terminal',
 'LINKCC': 'gcc-4.0',
 'LINKFORSHARED': '-u _PyMac_Error Python.framework/Versions/2.7/Python',
 'LN': 'ln',
 'LOCALMODLIBS': '',
 'MACHDEP': 'darwin',
 'MACHDEPPATH': ':plat-darwin',
 'MACHDEPS': 'plat-darwin plat-mac plat-mac/Carbon
plat-mac/lib-scriptpackages \tplat-mac/lib-scriptpackages/_builtinSuites
\tplat-mac/lib-scriptpackages/CodeWarrior
\tplat-mac/lib-scriptpackages/Explorer \tplat-mac/lib-scriptpackages/Finder
\tplat-mac/lib-scriptpackages/Netscape
\tplat-mac/lib-scriptpackages/StdSuites
\tplat-mac/lib-scriptpackages/SystemEvents
\tplat-mac/lib-scriptpackages/Terminal',
 'MACHDEP_OBJS': 'Python/mactoolboxglue.o',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 'MACOSX_DEPLOYMENT_TARGET': '10.5',
 'MAINCC': 'gcc-4.0',
 'MAKESETUP': '/Users/sysadmin/X/r27/Modules/makesetup',
 'MANDIR': '/Library/Frameworks/Python.framework/Versions/2.7/share/man',
 'MEMTESTOPTS': '-l -x test_subprocess test_io test_lib2to3
\t\ttest_multibytecodec test_urllib2_localnet test_itertools
\t\ttest_multiprocessing test_mailbox test_socket test_poll \t\ttest_select
test_zipfile -x test_dl test___all__ test_fork1 \t\ttest_longexp',
 'MODLIBS': '',
 'MODOBJS': 'Modules/threadmodule.o  Modules/signalmodule.o
 Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o
 Modules/_sre.o  Modules/_codecsmodule.o  Modules/zipimport.o
 Modules/symtablemodule.o  Modules/xxsubtype.o',
 'MODULE_OBJS': 'Modules/config.o \t\tModules/getpath.o \t\tModules/main.o
\t\tModules/gcmodule.o',
 'OBJECT_OBJS': 'Objects/abstract.o \t\tObjects/boolobject.o
\t\tObjects/bufferobject.o \t\tObjects/bytes_methods.o
\t\tObjects/bytearrayobject.o \t\tObjects/capsule.o \t\tObjects/cellobject.o
\t\tObjects/classobject.o \t\tObjects/cobject.o \t\tObjects/codeobject.o
\t\tObjects/complexobject.o \t\tObjects/descrobject.o
\t\tObjects/enumobject.o \t\tObjects/exceptions.o \t\tObjects/genobject.o
\t\tObjects/fileobject.o \t\tObjects/floatobject.o \t\tObjects/frameobject.o
\t\tObjects/funcobject.o \t\tObjects/intobject.o \t\tObjects/iterobject.o
\t\tObjects/listobject.o \t\tObjects/longobject.o \t\tObjects/dictobject.o
\t\tObjects/memoryobject.o \t\tObjects/methodobject.o
\t\tObjects/moduleobject.o \t\tObjects/object.o \t\tObjects/obmalloc.o
\t\tObjects/rangeobject.o \t\tObjects/setobject.o \t\tObjects/sliceobject.o
\t\tObjects/stringobject.o \t\tObjects/structseq.o \t\tObjects/tupleobject.o
\t\tObjects/typeobject.o \t\tObjects/weakrefobject.o
\t\tObjects/unicodeobject.o Objects/unicodectype.o',
 'OLDPATH': ':lib-old',
 'OPT': '-DNDEBUG -g -O3',
 'OTHER_LIBTOOL_OPT': '',
 'PARSER_HEADERS': 'Parser/parser.h \t\tParser/tokenizer.h',
 'PARSER_OBJS': 'Parser/acceler.o \t\tParser/grammar1.o
\t\tParser/listnode.o \t\tParser/node.o \t\tParser/parser.o
\t\tParser/parsetok.o \t\tParser/bitset.o \t\tParser/metagrammar.o
\t\tParser/firstsets.o \t\tParser/grammar.o \t\tParser/pgen.o
Parser/myreadline.o Parser/tokenizer.o',
 'PGEN': 'Parser/pgen',
 'PGENMAIN': '',
 'PGENOBJS': 'Parser/acceler.o \t\tParser/grammar1.o \t\tParser/listnode.o
\t\tParser/node.o \t\tParser/parser.o \t\tParser/parsetok.o
\t\tParser/bitset.o \t\tParser/metagrammar.o \t\tParser/firstsets.o
\t\tParser/grammar.o \t\tParser/pgen.o Objects/obmalloc.o
\t\tPython/mysnprintf.o \t\tPython/pyctype.o \t\tParser/tokenizer_pgen.o
\t\tParser/printgrammar.o \t\tParser/pgenmain.o',
 'PGOBJS': 'Objects/obmalloc.o \t\tPython/mysnprintf.o \t\tPython/pyctype.o
\t\tParser/tokenizer_pgen.o \t\tParser/printgrammar.o
\t\tParser/pgenmain.o',
 'PLATDIR': 'plat-darwin',
 'PLATMACDIRS': 'plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages
\tplat-mac/lib-scriptpackages/_builtinSuites
\tplat-mac/lib-scriptpackages/CodeWarrior
\tplat-mac/lib-scriptpackages/Explorer \tplat-mac/lib-scriptpackages/Finder
\tplat-mac/lib-scriptpackages/Netscape
\tplat-mac/lib-scriptpackages/StdSuites
\tplat-mac/lib-scriptpackages/SystemEvents
\tplat-mac/lib-scriptpackages/Terminal',
 'PLATMACPATH': ':plat-mac:plat-mac/lib-scriptpackages',
 'POBJS': 'Parser/acceler.o \t\tParser/grammar1.o \t\tParser/listnode.o
\t\tParser/node.o \t\tParser/parser.o \t\tParser/parsetok.o
\t\tParser/bitset.o \t\tParser/metagrammar.o \t\tParser/firstsets.o
\t\tParser/grammar.o \t\tParser/pgen.o',
 'PROFILE_TASK': '/Users/sysadmin/X/r27/Tools/pybench/pybench.py -n 2
--with-gc --with-syscheck',
 'PURIFY': '',
 'PYTHON': 'python',
 'PYTHONFRAMEWORK': 'Python',
 'PYTHONFRAMEWORKDIR': 'Python.framework',
 'PYTHONFRAMEWORKINSTALLDIR': '/Library/Frameworks/Python.framework',
 'PYTHONFRAMEWORKPREFIX': '/Library/Frameworks',
':plat-darwin:plat-mac:plat-mac/lib-scriptpackages:lib-tk:lib-old',
 'PYTHON_HEADERS': 'Include/Python-ast.h \t\tInclude/Python.h
\t\tInclude/abstract.h \t\tInclude/asdl.h \t\tInclude/ast.h
\t\tInclude/bitset.h \t\tInclude/boolobject.h \t\tInclude/bytearrayobject.h
\t\tInclude/bytes_methods.h \t\tInclude/bytesobject.h
\t\tInclude/bufferobject.h \t\tInclude/cellobject.h \t\tInclude/ceval.h
\t\tInclude/classobject.h \t\tInclude/cobject.h \t\tInclude/code.h
\t\tInclude/codecs.h \t\tInclude/compile.h \t\tInclude/complexobject.h
\t\tInclude/descrobject.h \t\tInclude/dictobject.h \t\tInclude/dtoa.h
\t\tInclude/enumobject.h \t\tInclude/errcode.h \t\tInclude/eval.h
\t\tInclude/fileobject.h \t\tInclude/floatobject.h \t\tInclude/frameobject.h
\t\tInclude/funcobject.h \t\tInclude/genobject.h \t\tInclude/import.h
\t\tInclude/intobject.h \t\tInclude/intrcheck.h \t\tInclude/iterobject.h
\t\tInclude/listobject.h \t\tInclude/longintrepr.h \t\tInclude/longobject.h
\t\tInclude/marshal.h \t\tInclude/memoryobject.h \t\tInclude/metagrammar.h
\t\tInclude/methodobject.h \t\tInclude/modsupport.h
\t\tInclude/moduleobject.h \t\tInclude/node.h \t\tInclude/object.h
\t\tInclude/objimpl.h \t\tInclude/opcode.h \t\tInclude/osdefs.h
\t\tInclude/parsetok.h \t\tInclude/patchlevel.h \t\tInclude/pgen.h
\t\tInclude/pgenheaders.h \t\tInclude/pyarena.h \t\tInclude/pycapsule.h
\t\tInclude/pyctype.h \t\tInclude/pydebug.h \t\tInclude/pyerrors.h
\t\tInclude/pyfpe.h \t\tInclude/pymath.h \t\tInclude/pygetopt.h
\t\tInclude/pymem.h \t\tInclude/pyport.h \t\tInclude/pystate.h
\t\tInclude/pystrcmp.h \t\tInclude/pystrtod.h \t\tInclude/pythonrun.h
\t\tInclude/pythread.h \t\tInclude/rangeobject.h \t\tInclude/setobject.h
\t\tInclude/sliceobject.h \t\tInclude/stringobject.h
\t\tInclude/structmember.h \t\tInclude/structseq.h \t\tInclude/symtable.h
\t\tInclude/sysmodule.h \t\tInclude/traceback.h \t\tInclude/tupleobject.h
\t\tInclude/ucnhash.h \t\tInclude/unicodeobject.h \t\tInclude/warnings.h
\t\tInclude/weakrefobject.h \t\tpyconfig.h \t\tParser/parser.h
\t\tParser/tokenizer.h',
 'PYTHON_OBJS': 'Python/_warnings.o \t\tPython/Python-ast.o
\t\tPython/asdl.o \t\tPython/ast.o \t\tPython/bltinmodule.o
\t\tPython/ceval.o \t\tPython/compile.o \t\tPython/codecs.o
\t\tPython/errors.o \t\tPython/frozen.o \t\tPython/frozenmain.o
\t\tPython/future.o \t\tPython/getargs.o \t\tPython/getcompiler.o
\t\tPython/getcopyright.o \t\tPython/getplatform.o \t\tPython/getversion.o
\t\tPython/graminit.o \t\tPython/import.o \t\tPython/importdl.o
\t\tPython/marshal.o \t\tPython/modsupport.o \t\tPython/mystrtoul.o
\t\tPython/mysnprintf.o \t\tPython/peephole.o \t\tPython/pyarena.o
\t\tPython/pyctype.o \t\tPython/pyfpe.o \t\tPython/pymath.o
\t\tPython/pystate.o \t\tPython/pythonrun.o \t\tPython/structmember.o
\t\tPython/symtable.o \t\tPython/sysmodule.o \t\tPython/traceback.o
\t\tPython/getopt.o \t\tPython/pystrcmp.o \t\tPython/pystrtod.o
\t\tPython/dtoa.o \t\tPython/formatter_unicode.o
\t\tPython/formatter_string.o \t\tPython/dynload_shlib.o \t\t
\t\tPython/mactoolboxglue.o \t\tPython/thread.o',
 'PY_CFLAGS': '-fno-strict-aliasing -fno-common -dynamic -arch i386 -arch
ppc -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I. -IInclude
-I/Users/sysadmin/X/r27/Include  -DPy_BUILD_CORE',
 'QUICKTESTOPTS': '-l -x test_subprocess test_io test_lib2to3
\t\ttest_multibytecodec test_urllib2_localnet test_itertools
\t\ttest_multiprocessing test_mailbox test_socket test_poll \t\ttest_select
test_zipfile',
 'RANLIB': 'ranlib',
 'RESSRCDIR': 'Mac/Resources/framework',
 'RUNSHARED': 'DYLD_FRAMEWORK_PATH=/private/tmp/_py/_bld/python:',
 'SCRIPTDIR': '/Library/Frameworks/Python.framework/Versions/2.7/lib',
 'SGI_ABI': '',
 'SHELL': '/bin/sh',
 'SHLIBS': '-ldl  -framework CoreFoundation',
 'SIGNAL_OBJS': '',
 'SITEPATH': '',
 'SO': '.so',
 'SRCDIRS': 'Parser Grammar Objects Python Modules Mac',
 'SRC_GDB_HOOKS': '/Users/sysadmin/X/r27/Tools/gdb/libpython.py',
 'STRINGLIB_HEADERS': '/Users/sysadmin/X/r27/Include/bytes_methods.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/count.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/ctype.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/fastsearch.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/find.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/formatter.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/partition.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/split.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/stringdefs.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/string_format.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/transmogrify.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/unicodedefs.h
\t\t/Users/sysadmin/X/r27/Objects/stringlib/localeutil.h',
 'SUBDIRS': '',
 'SUBDIRSTOO': 'Include Lib Misc Demo',
 'SVNVERSION': 'svnversion /Users/sysadmin/X/r27',
 'SYSLIBS': '',
 'TESTOPTS': '-l',
 'TESTPATH': '',
 'TESTPROG': '/Users/sysadmin/X/r27/Lib/test/regrtest.py',
./python.exe -Wd -3 -E -tt',
 'THREADOBJ': 'Python/thread.o',
 'TKPATH': ':lib-tk',
 'UNICODE_OBJS': 'Objects/unicodeobject.o Objects/unicodectype.o',
 'UNIVERSALSDK': '/',
 'VERSION': '2.7',
 'VPATH': '/Users/sysadmin/X/r27',
 'XMLLIBSUBDIRS': 'xml xml/dom xml/etree xml/parsers xml/sax',
 'datarootdir': '/Library/Frameworks/Python.framework/Versions/2.7/share',
 'exec_prefix': '/Library/Frameworks/Python.framework/Versions/2.7',
 'prefix': '/Library/Frameworks/Python.framework/Versions/2.7',
 'srcdir': '/Users/sysadmin/X/r27'}
Daniel-Francas-MacBook-Pro:psycopg2-2.2.1 danielfranca$
Daniel-Francas-MacBook-Pro:psycopg2-2.2.1 danielfranca$ python -c 'import
platform; print platform.architecture()'
('64bit', '')
Daniel-Francas-MacBook-Pro:psycopg2-2.2.1 danielfranca$
Daniel-Francas-MacBook-Pro:psycopg2-2.2.1 danielfranca$ python -c 'import
platform; print platform.machine()'
i386
Daniel-Francas-MacBook-Pro:psycopg2-2.2.1 danielfranca$
Daniel-Francas-MacBook-Pro:psycopg2-2.2.1 danielfranca$ python -c 'import
platform; print platform.mac_ver()'
('10.6.4', ('', '', ''), 'i386')
Post by Daniel França
Hi,
I recently migrated from Linux to Mac OS X, and I'm trying to get my django
project working.
I'm getting problems trying to install psycopg2
I installed that, both when I try to run my django server I get the
*
*
*gresql_psycopg2/base.py", line 24, in<module>*
*    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)*
dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so,
2): Symbol not found: _PQbackendPID*
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
*
*  Expected in: flat namespace*
* in
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
*
I have seen this error reported several times on IRC and on this list. It
usually has something to do with either _psycopg.so, libpq.so or the python
interpreter being built with the incorrect architectures.
file /path/to/libpq.so.X.X
file /path/to/_psycopg.so
python -c 'import pprint; from distutils import sysconfig;
pprint.pprint(sysconfig.parse_makefile(sysconfig.get_makefile_filename()))'
python -c 'import platform; print platform.architecture()'
python -c 'import platform; print platform.machine()'
python -c 'import platform; print platform.mac_ver()'
psql -c 'select version()'
And also googling for your error. I have seen reports of people solving
that problem by switching their system python into 32 bit mode, but then
again I have seen people for which it did not work.
Cheers,
Jan
Daniele Varrazzo
2010-08-03 14:52:25 UTC
Permalink
Post by Daniel França
ok, this error doesn't happen anymore, I installed python32bits
My website is running, but when I try to insert some data at the
Can't adapt type <<timezone>>
I tried to use timezone as 'US/Eastern', 'America/Sao_Paulo'
but the problem remains.
Maybe it's because my postgresql is 64 bits? How do I know if it is?
can anyone help me?
Hello,

no, you are past the 32/64 bits problem: now psycopg seems running fine.

Psycopg doesn't know what the object you are trying to pass to the
query is (timezone). Is it a class of yours or something else? Can you
provide an example of the query you are trying to run and the objects
you are passing it?

I don't think postgres has a "timezone" data type: maybe you want to
save a timestamp with time zone instead.

Regards,

-- Daniele
Daniel França
2010-08-03 14:59:21 UTC
Permalink
Hi Daniele, I'm not at home right now(where the error happens), but
I'll try to explain.
I'm using psycopg2 w/ django.
in django there's a timezone env. variable that I set in a settings file.
something like this:
TIMEZONE="US/Eastern"

the problem is, whatever I put there I get a message error like this:
"Can't adapt type 'US/Eastern'"
if I change to TIMEZONE="America/Sao_Paulo" I get: "Can't adapt type
'America/Sao_Paulo'"
it was working fine this way in GNU/Linux, but now in Mac OSX I got
this error. Perhaps it's something internal to django framework?
Post by Daniele Varrazzo
Post by Daniel França
ok, this error doesn't happen anymore, I installed python32bits
My website is running, but when I try to insert some data at the
Can't adapt type <<timezone>>
I tried to use timezone as 'US/Eastern', 'America/Sao_Paulo'
but the problem remains.
Maybe it's because my postgresql is 64 bits? How do I know if it is?
can anyone help me?
Hello,
no, you are past the 32/64 bits problem: now psycopg seems running fine.
Psycopg doesn't know what the object you are trying to pass to the
query is (timezone). Is it a class of yours or something else? Can you
provide an example of the query you are trying to run and the objects
you are passing it?
I don't think postgres has a "timezone" data type: maybe you want to
save a timestamp with time zone instead.
Regards,
-- Daniele
Daniele Varrazzo
2010-08-03 15:49:12 UTC
Permalink
Post by Daniel França
Hi Daniele, I'm not at home right now(where the error happens), but
I'll try to explain.
I'm using psycopg2 w/ django.
in django there's a timezone env. variable that I set in a settings file.
TIMEZONE="US/Eastern"
"Can't adapt type 'US/Eastern'"
if I change to TIMEZONE="America/Sao_Paulo" I get: "Can't adapt type
'America/Sao_Paulo'"
it was working fine this way in GNU/Linux, but now in Mac OSX I got
this error. Perhaps  it's something internal to django framework?
Yes, looks like every timezone in django is a type on its own. Maybe
on Linux you tested with a previous version where the timezones were
just strings. If this is the case, maybe passing
str(settings.TIMEZONE) will work.

I've django 1.2 installed anyway and here:

- the setting I have is called TIME_ZONE, not TIMEZONE
- this setting is a string.

Are you testing with django trunk? Can you report what the setting
really is from an interactive shell?

python /path/to/project/manage.py shell
Post by Daniel França
from django.conf import settings
settings.TIME_ZONE
'London/Europe'
Post by Daniel França
type(settings.TIME_ZONE)
<type 'str'>
Post by Daniel França
import django
print django.VERSION
(1, 2, 0, 'final', 0)

Just to check we are talking about the same thing...

-- Daniele
Daniel França
2010-08-05 03:19:13 UTC
Permalink
I think I found exactly where the error happens and I reproduced it in the
from django.contrib.auth.models import User
"daniel")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py",
line 129, in create_user
user.save(using=self._db)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py",
line 435, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py",
line 543, in save_base
created=(not record_exists), raw=raw)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py",
line 162, in send
response = receiver(signal=self, sender=sender, **named)
File
"/Users/danielfranca/workspace/django/view/tint/apps/account/models.py",
line 60, in create_account
account, created = Account.objects.get_or_create(user=instance)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py",
line 135, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py",
line 373, in get_or_create
obj.save(force_insert=True, using=self.db)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py",
line 435, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py",
line 528, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py",
line 195, in _insert
return insert_query(self.model, values, **kwargs)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py",
line 1479, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
line 783, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
line 727, in execute_sql
cursor.execute(sql, params)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/util.py",
line 15, in execute
return self.cursor.execute(sql, params)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py",
line 44, in execute
return self.cursor.execute(query, args)
DatabaseError: can't adapt type 'US/Eastern'

it's when I try to create a new user, maybe it has nothing to do with
psycopg, right?
My output is below, and my version of Django is 1.2.1 as you can see
below.
I had to include other imports and lines to allow the right output (is
it a
bad thing?)
"manage.py shell" configures this stuff for you
type(settings.TIME_ZONE)
<type 'str'>
So it's a plain string, the error "can't adapt 'US/Eastern'" can't
come from there. If there was a problem in psycopg and the string
adapter was not registered, you would get a "can't adapt type 'str'"
error, with the type name, not the value.
Can you post an example of what you are doing that gives you the
error? Can you reproduce it in an interactive shell?
-- Daniele
We have left the mailing list out of this discussion. Please include
it again in your answer.
-- Daniele
Daniele Varrazzo
2010-08-06 00:19:32 UTC
Permalink
Post by Daniel França
I think I found exactly where the error happens and I reproduced it in the
from django.contrib.auth.models import User
"daniel")
...
Post by Daniel França
DatabaseError: can't adapt type 'US/Eastern'
it's when I try to create a new user, maybe it has nothing to do with
psycopg, right?
The error is raised by psycopg, but it is due to some external cause.
I've installed Python 2.7 and easy_installed django 1.2.1 and psycopg
2.2.2: With this setup on Linux I can't reproduce your bug (the user
is created correctly). So the problem seems related to osx or to the
way you have put together your packages.

I can't be more helpful, sorry: I am not an osx user.

-- Daniele
Daniel França
2010-08-09 12:54:36 UTC
Permalink
here:
def create_account(sender, instance=None, **kwargs):
if instance is None:
return
account, created = Account.objects.get_or_create(user=instance)

post_save.connect(create_account, sender=User)

If I comment the *post_save.connect*, there's no exception =) but, of course
the code doesn't do what it should do.

so, the error is here, but I don't know how to solve, anyone?
I think we are almost there :P
user = models.ForeignKey(User, unique=True, verbose_name=_('user'))
timezone = TimeZoneField(_('timezone'))
language = models.CharField(_('language'), max_length=10,
choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE)
return self.user.username
maybe the error has something to do with it?
=/
thanks Daniele, I'll see here what I ca do from now
Post by Daniele Varrazzo
Post by Daniel França
I think I found exactly where the error happens and I reproduced it in
the
Post by Daniel França
from django.contrib.auth.models import User
new_user = User.objects.create_user("daniel", "
"daniel")
...
Post by Daniel França
DatabaseError: can't adapt type 'US/Eastern'
it's when I try to create a new user, maybe it has nothing to do with
psycopg, right?
The error is raised by psycopg, but it is due to some external cause.
I've installed Python 2.7 and easy_installed django 1.2.1 and psycopg
2.2.2: With this setup on Linux I can't reproduce your bug (the user
is created correctly). So the problem seems related to osx or to the
way you have put together your packages.
I can't be more helpful, sorry: I am not an osx user.
-- Daniele
Joe Abbate
2010-08-03 14:16:40 UTC
Permalink
Post by Daniel França
Maybe it's because my postgresql is 64 bits? How do I know if it is?
can anyone help me?
select version(); issued against any database should (usually) tell
you: PG version, compiler used and OS.

Joe
Charlie Clark
2010-07-13 10:38:20 UTC
Permalink
Post by Daniel França
I don't know why it's happening, mayble incorrect version?
I'm using Python 2.7 and Postgresql8.4 and Psycopg 2.2.1
As Jan says there may be problems with 32-bit / 64-bit versions.

I suggest you use MacPorts versions of Python and Postgres. Python 2.7,
psycopg2 and Postgres 8.4 work fine for me.

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226
Daniele Varrazzo
2010-07-13 11:14:11 UTC
Permalink
Post by Charlie Clark
Post by Daniel França
I don't know why it's happening, mayble incorrect version?
I'm using Python 2.7 and Postgresql8.4 and Psycopg 2.2.1
As Jan says there may be problems with 32-bit / 64-bit versions.
I suggest you use MacPorts versions of Python and Postgres. Python 2.7,
psycopg2 and Postgres 8.4 work fine for me.
Hello,

please, could anybody write the text of one or two FAQ+A regarding
compiling/using psycopg on Mac OS X? I'd like to add them to
<http://initd.org/psycopg/docs/faq.html>. I've read about problems
raised from time to time but I don't follow closely the threads as I
don't know the platforms nor anything about the MacPorts - which seem
usually addressed as a solution.

Thank you very much,

-- Daniele
Daniel França
2010-07-18 04:57:03 UTC
Permalink
I tried to run in 32bits mode this way: "arch -i386 python"
that's is right?

If i just run something like: *"arch -i386 python -c 'import psycopg2' "*
*It's ok, no error happens (and without arch -i386 the error happens)*
*
*
*but when I run my manage.py django app, nothing changes, same error *
*I tried to create an alias -> alias python="arch -i386 python"*
*but no success =/
*
Hi all,
I tried a lot of things with no successfull yet =/
I've tried to install using Mac Ports (Porticus) and I get the error in
:info:configure configure: error: library 'xml2' (version >= 2.6.23) is
required for XML support
:info:configure shell command " cd
"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_postgresql84/work/postgresql-8.4.4"
&& ./configure --prefix=/opt/local --disable-dependency-tracking
--sysconfdir=/opt/local/etc/postgresql84
--bindir=/opt/local/lib/postgresql84/bin
--libdir=/opt/local/lib/postgresql84
--includedir=/opt/local/include/postgresql84
--datadir=/opt/local/share/postgresql84 --mandir=/opt/local/share/man
--without-docdir --with-includes=/opt/local/include
--with-libraries=/opt/local/lib --with-openssl --with-bonjour
--with-readline --with-zlib --with-libxml --with-libxslt
--enable-thread-safety --enable-integer-datetimes --with-ossp-uuid "
returned error 1
shell command failed
But libxml was 2.7, I don't know why it's not recognizing, so I uninstalled
Error: You cannot install libxml2 for the architecture(s) x86_64 i386
because
Error: its dependency libiconv only contains the architecture(s) i386 ppc.
And if I try to install psycopg2 using easy_install or compiling the
source, it seems work fine, but I still can't start my django application
with the same error before.
what else can I do?
On Tue, Jul 13, 2010 at 8:14 AM, Daniele Varrazzo <
Post by Daniele Varrazzo
Post by Charlie Clark
Post by Daniel França
I don't know why it's happening, mayble incorrect version?
I'm using Python 2.7 and Postgresql8.4 and Psycopg 2.2.1
As Jan says there may be problems with 32-bit / 64-bit versions.
I suggest you use MacPorts versions of Python and Postgres. Python 2.7,
psycopg2 and Postgres 8.4 work fine for me.
Hello,
please, could anybody write the text of one or two FAQ+A regarding
compiling/using psycopg on Mac OS X? I'd like to add them to
<http://initd.org/psycopg/docs/faq.html>. I've read about problems
raised from time to time but I don't follow closely the threads as I
don't know the platforms nor anything about the MacPorts - which seem
usually addressed as a solution.
Thank you very much,
-- Daniele
_______________________________________________
Psycopg mailing list
http://lists.initd.org/mailman/listinfo/psycopg
Daniel França
2010-07-18 04:57:29 UTC
Permalink
Hi all,
I tried a lot of things with no successfull yet =/
I've tried to install using Mac Ports (Porticus) and I get the error in
:info:configure configure: error: library 'xml2' (version >= 2.6.23) is
required for XML support
:info:configure shell command " cd
"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_postgresql84/work/postgresql-8.4.4"
&& ./configure --prefix=/opt/local --disable-dependency-tracking
--sysconfdir=/opt/local/etc/postgresql84
--bindir=/opt/local/lib/postgresql84/bin
--libdir=/opt/local/lib/postgresql84
--includedir=/opt/local/include/postgresql84
--datadir=/opt/local/share/postgresql84 --mandir=/opt/local/share/man
--without-docdir --with-includes=/opt/local/include
--with-libraries=/opt/local/lib --with-openssl --with-bonjour
--with-readline --with-zlib --with-libxml --with-libxslt
--enable-thread-safety --enable-integer-datetimes --with-ossp-uuid "
returned error 1
shell command failed
But libxml was 2.7, I don't know why it's not recognizing, so I uninstalled
Error: You cannot install libxml2 for the architecture(s) x86_64 i386
because
Error: its dependency libiconv only contains the architecture(s) i386 ppc.
And if I try to install psycopg2 using easy_install or compiling the
source, it seems work fine, but I still can't start my django application
with the same error before.
what else can I do?
On Tue, Jul 13, 2010 at 8:14 AM, Daniele Varrazzo <
Post by Daniele Varrazzo
Post by Charlie Clark
Post by Daniel França
I don't know why it's happening, mayble incorrect version?
I'm using Python 2.7 and Postgresql8.4 and Psycopg 2.2.1
As Jan says there may be problems with 32-bit / 64-bit versions.
I suggest you use MacPorts versions of Python and Postgres. Python 2.7,
psycopg2 and Postgres 8.4 work fine for me.
Hello,
please, could anybody write the text of one or two FAQ+A regarding
compiling/using psycopg on Mac OS X? I'd like to add them to
<http://initd.org/psycopg/docs/faq.html>. I've read about problems
raised from time to time but I don't follow closely the threads as I
don't know the platforms nor anything about the MacPorts - which seem
usually addressed as a solution.
Thank you very much,
-- Daniele
_______________________________________________
Psycopg mailing list
http://lists.initd.org/mailman/listinfo/psycopg
Loading...