Why pysqlite does not work properly? - python

I tried to install pysqlite. Some suspicious things start to appear during the installation. Why I typed:
python setup.py build
I got the following message in the end:
src/module.c:286: error: ‘SQLITE_PRAGMA’ undeclared here (not in a function)
src/module.c:287: error: ‘SQLITE_READ’ undeclared here (not in a function)
src/module.c:288: error: ‘SQLITE_SELECT’ undeclared here (not in a function)
src/module.c:289: error: ‘SQLITE_TRANSACTION’ undeclared here (not in a function)
src/module.c:290: error: ‘SQLITE_UPDATE’ undeclared here (not in a function)
src/module.c:291: error: ‘SQLITE_ATTACH’ undeclared here (not in a function)
src/module.c:292: error: ‘SQLITE_DETACH’ undeclared here (not in a function)
src/module.c: In function ‘init_sqlite’:
src/module.c:419: warning: implicit declaration of function ‘sqlite3_libversion’
src/module.c:419: warning: passing argument 1 of ‘PyString_FromString’ makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1
I just ignored the last line and decided to continue. So, I typed:
python setup.py install
And than, again, I got similar error message:
src/module.c:288: error: ‘SQLITE_SELECT’ undeclared here (not in a function)
src/module.c:289: error: ‘SQLITE_TRANSACTION’ undeclared here (not in a function)
src/module.c:290: error: ‘SQLITE_UPDATE’ undeclared here (not in a function)
src/module.c:291: error: ‘SQLITE_ATTACH’ undeclared here (not in a function)
src/module.c:292: error: ‘SQLITE_DETACH’ undeclared here (not in a function)
src/module.c: In function ‘init_sqlite’:
src/module.c:419: warning: implicit declaration of function ‘sqlite3_libversion’
src/module.c:419: warning: passing argument 1 of ‘PyString_FromString’ makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1
After that I wanted to try if pysqlite works.
If in the python-command-line mode I type
from pysqlite2 import *
Python does not complain. However, if I try to follow an exmaple in my book:
from pysqlite2 import dbapi2 as sqlite
I get a error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pysqlite2/dbapi2.py", line 27, in <module>
from pysqlite2._sqlite import *
ImportError: No module named _sqlite
Does anybody have any ideas why it happens and how this problem can be solved. By the way, I have installed a new version of Python. "python -V" gives me "Python 2.6.2". Thank you in advance for any help.

I just ignored the last line and decided to continue.
You can't just ignore the last line. It was telling you there was an error, so it couldn't compile. The next thing you ran told you it couldn't install because it couldn't compile. Then, your python told you it couldn't run the code because it wasn't installed. You need to get the compile step working before you move on to installing it.

A lesson in compiling python extensions is needed, which distribution are you using ? You seem to be missing the sqlite headers with the given macro definitions. When the python setup runs it compiles bindings to the sqlite native binary and copies a few .py files to the library. The _sqlite is typically a .pyd file (equivalent to a dll) which has calls to the sqlite library, in your case that did not get built.
Check the presence of the sqlite headers etc.

The correct way to build pysqlite is now on the website.
$ tar xvfz <version>.tar.gz
$ cd <version>
$ python setup.py build_static install
The build_static will download the latest sqlite code and statically compile against it. For a note I just did this on a 1and1 shared host.
http://trac.edgewall.org/wiki/PySqlite#Buildingpysqlite

Related

Issues installing a python wrapper for a C program on Linux Subsystem for Windows

I am trying to use a new bioinformatics program written in C named 'Giggle'. They have included a python wrapper. Since I am on Windows 10 most of the bioinformatics stuff is only available for Linux, I am using the Linux subssystem with python 2 installed. The installation for the wrapper are as follows:
git clone --recursive https://github.com/brentp/python-giggle
cd python-giggle
python setup.py test
python setup.py install
When running the setup.py test I encountered all sorts of dependencies of which I had never heard like libbz2 and liblzma. Installation of these dependencies worked fine with sudo apt-get install but now upon running the test I get a long list of warnings like this one:
lib/htslib/hfile_libcurl.c:187:13: warning: function declaration isn’t a
prototype [-Wstrict-prototypes]
static void libcurl_exit()
These are all for different .h and .c files. The list ends with several errors:
lib/htslib/hfile_s3.c:70:2: error: #error No HMAC() routine found by configure
#error No HMAC() routine found by configure
^
lib/htslib/hfile_s3.c: In function ‘s3_rewrite’:
lib/htslib/hfile_s3.c:335:30: error: ‘DIGEST_BUFSIZ’ undeclared (first use in this function)
unsigned char digest[DIGEST_BUFSIZ];
^
lib/htslib/hfile_s3.c:335:30: note: each undeclared identifier is reported only once for each function it appears in
lib/htslib/hfile_s3.c:336:29: warning: implicit declaration of function ‘s3_sign’ [-Wimplicit-function-declaration]
size_t digest_len = s3_sign(digest, &secret, &message);
^
lib/htslib/hfile_s3.c:335:23: warning: unused variable ‘digest’ [-Wunused-variable]
unsigned char digest[DIGEST_BUFSIZ];
^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
I am kind of lost on this and googling the errors has not made me any wiser. I feel like it is a 'you are still using windows' kind of problem. Any help would be much appreciated.

Installing rpy on redhat

I'm new to RedHat but have been using Ubuntu for a while. I'm trying to install rpy2 using pip install rpy2 and I get the error
/usr/include/features.h:164:1: warning: this is the location of the previous definition
./rpy/rinterface/_rinterface.c:86:31: error: readline/readline.h: No such file or directory
In file included from ./rpy/rinterface/_rinterface.c:122:
./rpy/rinterface/embeddedr.c: In function ‘SexpObject_CObject_destroy’:
./rpy/rinterface/embeddedr.c:68: warning: implicit declaration of function ‘PyCapsule_GetPointer’
./rpy/rinterface/embeddedr.c:69: warning: cast to pointer from integer of different size
./rpy/rinterface/embeddedr.c: In function ‘Rpy_PreserveObject’:
./rpy/rinterface/embeddedr.c:107: warning: implicit declaration of function ‘PyCapsule_New’
./rpy/rinterface/embeddedr.c:109: warning: assignment makes pointer from integer without a cast
./rpy/rinterface/embeddedr.c:122: warning: cast to pointer from integer of different size
./rpy/rinterface/embeddedr.c: In function ‘Rpy_ReleaseObject’:
./rpy/rinterface/embeddedr.c:178: warning: cast to pointer from integer of different size
./rpy/rinterface/embeddedr.c: In function ‘Rpy_ProtectedIDs’:
./rpy/rinterface/embeddedr.c:301: warning: cast to pointer from integer of different size
In file included from ./rpy/rinterface/_rinterface.c:125:
./rpy/rinterface/sexp.c: In function ‘Sexp_sexp_set’:
./rpy/rinterface/sexp.c:282: warning: implicit declaration of function ‘PyCapsule_CheckExact’
./rpy/rinterface/sexp.c:288: warning: cast to pointer from integer of different size
./rpy/rinterface/sexp.c: In function ‘Sexp_init’:
./rpy/rinterface/sexp.c:738: warning: unused variable ‘copy’
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_init’:
./rpy/rinterface/_rinterface.c:1333: error: ‘rl_completer_word_break_characters’ undeclared (first use in this function)
./rpy/rinterface/_rinterface.c:1333: error: (Each undeclared identifier is reported only once
./rpy/rinterface/_rinterface.c:1333: error: for each function it appears in.)
./rpy/rinterface/_rinterface.c:1336: error: ‘rl_basic_word_break_characters’ undeclared (first use in this function)
./rpy/rinterface/_rinterface.c: In function ‘init_rinterface’:
./rpy/rinterface/_rinterface.c:3688: warning: assignment makes pointer from integer without a cast
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/rpy2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BynTYR-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-root/rpy2
Storing complete log in /root/.pip/pip.log
I know that I need something called adns as mentioned elsewhere, but can't figure out how to install in on RedHat. I tried downloading it and installing from file but that didn't work.
You need to sudo yum install readline-devel to get the readline header files needed to build.

Error with PyML build

I'm looking to start a Machine Learning project, and I attempted to install PyML (on Mac OS X 10.6.8). In doing so I received the following error while running python setup.py build.
PyML/containers/ext/SparseDataSet_wrap.cpp: At global scope:
PyML/containers/ext/SparseDataSet_wrap.cpp:17658: fatal error: error writing to -: Broken pipe
compilation terminated.
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++
PyML/containers/ext/SparseDataSet_wrap.cpp: In static member function ‘static Type swig::traits_as<Type, swig::value_category>::as(PyObject*, bool) [with Type = float]’:
PyML/containers/ext/SparseDataSet_wrap.cpp:3341: warning: ‘v’ may be used uninitialized in this function
PyML/containers/ext/SparseDataSet_wrap.cpp: In static member function ‘static Type swig::traits_as<Type, swig::value_category>::as(PyObject*, bool) [with Type = int]’:
PyML/containers/ext/SparseDataSet_wrap.cpp:3341: warning: ‘v’ may be used uninitialized in this function
lipo: can't open input file: /var/folders/BB/BB-0UcDKHzKgl2HboGzXqU+++TI/-Tmp-//ccf93ouC.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
I followed the following tutorial for the install process:
http://pyml.sourceforge.net/tutorial.html
Any suggestions on what might be causing it and how to fix it? Thanks.
I also had precisely the same problem using PyML on Ubuntu.
Installing the Python development package (python2.x-dev) resolved the issue. You need to install those Python development headers, installing XCode should also install the headers on Mac.
They are usually located in "/System/Library/Frameworks/Python.framework/Versions/2.6/"

error installing mod_wsgi on SUSE 11 server

apache version :2.2.6
python versoin :2.6
result of ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python is ok but just got some errors as follows when make:
....
mod_wsgi.c:14430: error: expected expression before âmoduleâ
mod_wsgi.c:14431: error: expected identifier or â(â before â=â token
mod_wsgi.c:14446: error: expected expression before âmoduleâ
mod_wsgi.c:14447: error: âmodule_dictâ undeclared (first use in this function)
mod_wsgi.c:14448: error: âobjectâ undeclared (first use in this function)
mod_wsgi.c:14450: error: expected expression before âmoduleâ
mod_wsgi.c:14454: error: âvarsâ undeclared (first use in this function)
mod_wsgi.c:14455: error: âargsâ undeclared (first use in this function)
mod_wsgi.c:14456: error: âresultâ undeclared (first use in this function)
mod_wsgi.c:14457: error: âmethodâ undeclared (first use in this function)
mod_wsgi.c:14474: error: âPy_Noneâ undeclared (first use in this function)
mod_wsgi.c:14488: error: âPy_Trueâ undeclared (first use in this function)
mod_wsgi.c:14491: error: âPy_Falseâ undeclared (first use in this function)
mod_wsgi.c:14503: error: âPyExc_TypeErrorâ undeclared (first use in this function)
mod_wsgi.c:14519: error: âAuthObjectâ has no member named ârâ
mod_wsgi.c:14523: error: âAuthObjectâ has no member named âlogâ
mod_wsgi.c:14526: error: âPyExc_AttributeErrorâ undeclared (first use in this function)
mod_wsgi.c:14528: error: âAuthObjectâ has no member named âlogâ
mod_wsgi.c:14541: error: expected expression before â)â token
mod_wsgi.c:14548: error: expected â;â before âap_log_rerrorâ
mod_wsgi.c:14553: error: expected â;â before â}â token
mod_wsgi.c:14558: error: too many arguments to function âwsgi_log_python_errorâ
mod_wsgi.c:14563: error: expected expression before âmoduleâ
apxs:Error: Command failed with rc=65536
.
make: *** [mod_wsgi.la] Error 1
Please advise me
i had the same error; i solved it by compileing python 2.7.2 from scratch; if you look around different forums you will see that some libraries of python where compiled on a 32 bit system and you problably are using a 64 bit system.
go for 2.7 or above 2.6 is a pain to compile due to all the missing dependencies that you have to get. you will end with something like this
Python build finished, but the necessary bits to build these modules were not found:
bsddb185 dl imageop
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Failed to build these modules:
_curses_panel
running build_scripts
this libraries have all been depreciated so it is safe to do a make install as is

Compiling gVim with Python 3 support

I hope this is the right place to ask this question:
I am trying to compile gVim with python 3 support using cygwin under windows:
I changed the Make_cyg.mak files Python section to the following:
##############################
# DYNAMIC_PYTHON=yes works.
# DYNAMIC_PYTHON=no does not (unresolved externals on link).
##############################
ifdef PYTHON
DEFINES += -DFEAT_PYTHON
INCLUDES += -I$(PYTHON)/include
EXTRA_OBJS += $(OUTDIR)/if_python.o
ifndef DYNAMIC_PYTHON
DYNAMIC_PYTHON = yes
endif
ifndef PYTHON_VER
PYTHON_VER = 30
endif
ifeq (yes, $(DYNAMIC_PYTHON))
DEFINES += -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python$(PYTHON_VER).dll\"
else
EXTRA_LIBS += $(PYTHON)/libs/python$(PYTHON_VER).lib
endif
endif
However when running:
$ make -f Make_cyg.mak OLE=Yes PYTHON=/cygdrive/p/Applications/PortablePython_1.1_py3.0.1/App/ RUBY=/cygdrive/c/Programme/Ruby/
this results in the following errors:
In file included from /cygdrive/p/Applications/PortablePython_1.1_py3.0.1/App//i
nclude/Python.h:70,
from if_python.c:43:
/cygdrive/p/Applications/PortablePython_1.1_py3.0.1/App//include/bytesobject.h:1
04:1: warning: "F_BLANK" redefined
In file included from globals.h:1554,
from vim.h:1831,
from if_python.c:20:
farsi.h:74:1: warning: this is the location of the previous definition
if_python.c:729: warning: initialization makes integer from pointer without a ca
st
if_python.c:733: warning: initialization from incompatible pointer type
if_python.c:734: warning: initialization from incompatible pointer type
if_python.c:735: warning: initialization from incompatible pointer type
if_python.c:737: error: `cmpfunc' undeclared here (not in a function)
if_python.c:737: error: initializer element is not constant
if_python.c:737: error: (near initialization for `OutputType.tp_repr')
if_python.c:737: error: parse error before numeric constant
/** more errors **/
if_python.c:2256: warning: initialization from incompatible pointer type
if_python.c:2257: warning: initialization from incompatible pointer type
if_python.c: In function `PythonMod_Init':
if_python.c:2351: error: structure has no member named `ob_type'
if_python.c:2352: error: structure has no member named `ob_type'
if_python.c:2353: error: structure has no member named `ob_type'
if_python.c:2354: error: structure has no member named `ob_type'
if_python.c:2355: error: structure has no member named `ob_type'
if_python.c:2356: error: structure has no member named `ob_type'
make: *** [gobj/if_python.o] Error 1
I am using a portable python install from Portable Python. I don't know if that may be the source of the error.
I am hoping someone knows how to compile vim with python 3 support (if I only compile it with ruby support it compiles nicely).
Thanks in advance,
Gjallar
I have compiled vim with python3 support. Here is the Patch updated for vim 7.2.411.
For compilation instruction check out my 2009 September 22 mail on
groups.google.com/group/vim_dev/browse_frm/month/2009-09
(adding a second hyperlink didn't work)
There is a lot of things going on at once here. First of all, why do you want Python 3.0? If you really want Python 3, then you should use Python 3.1.
Second of all, what does "Python 3 support" mean in the case of gVim? Is it to make extensions with Python? Then you don't want Python 3 support, as any extension that exists for gVim is going to be written for Python 2.
And yeah, it seems very strange to use portable python. Since you are compiling gVim with cygwin, you should reasonably use a Python compiled with the same Cygwin.
Doesn't the normal gvim for Windows have Python support?

Categories

Resources