classification
Title: import sqlite3 not running after configure --prefix=/alt/path; make; make install
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: alexganwd, berker.peksag, brett.cannon, donmez, dpatino, r.david.murray, vstinner
Priority: normal Keywords:

Created on 2014-07-10 10:00 by alexganwd, last changed 2018-07-23 06:09 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
make.log alexganwd, 2014-07-10 14:37 make.log
make_install.log alexganwd, 2014-07-18 07:05
Messages (16)
msg222656 - (view) Author: Alejandro (alexganwd) Date: 2014-07-10 10:00
We have compile python 3.4.1 in Suse Linux Enterprise Server 11 SP2

We have compiled it using --prefix as args :

./configure --prefix=/soft/pyt341

make 

make install

We check python has been properly installed:

/soft/pyt341/bin/python3 --version
Python 3.4.1


We try to import sqlite3 lib and we get this error:

/soft/pyt341/bin/python3 -c "import sqlite3"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/soft/pyt341/lib/python3.4/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/soft/pyt341/lib/python3.4/sqlite3/dbapi2.py", line 26, in <module>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'
msg222657 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-07-10 12:04
> We have compiled it using --prefix as args :

Did you install sqlite3-devel?
msg222659 - (view) Author: Alejandro (alexganwd) Date: 2014-07-10 12:19
Yes. We have these packages installed:

rpm -qa | grep sqlite
sqlite3-3.7.6.3-1.4.4.1
libsqlite3-0-3.7.6.3-1.4.4.1
sqlite3-devel-3.7.6.3-1.4.4.1
msg222668 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-07-10 14:24
The output from running `make` could help by pointing out either a compilation error or lack thereof to deduce that setup.py did not find the headers.
msg222670 - (view) Author: Alejandro (alexganwd) Date: 2014-07-10 14:37
Here you have (attached):  make.log
Thanks!
msg222733 - (view) Author: David (dpatino) Date: 2014-07-11 09:13
Hi, I've the same problem. 
I've already tested (from source, Python-3.4.1.tgz) under OpenSUSE 12.3 and Debian 7.5 with the same issue. I've compiled it in standard way (./configure; make; make install) although the output (error) is the same, after import sqlite3:

#python3 -c "import sqlite3"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.4/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/lib/python3.4/sqlite3/dbapi2.py", line 26, in <module>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'

However, if I install it using specific distro packages it works properly.
msg222734 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-07-11 09:46
Works for me on Ubuntu 12.04 LTS:

   $ sudo apt-get install sqlite3 libsqlite3-dev
   $ ./configure
   $ make -j3
   $ sudo make install
   $ sqlite3 -version
   3.7.9 2011-11-01 00:52:41 c7c6050ef060877ebe77b41d959e9df13f8c9b5e
   $ python3.4 -V
   3.4.1
   $ python3.4 -c "import sqlite3; print(sqlite3.sqlite_version)"
   3.7.9
msg222736 - (view) Author: Alejandro (alexganwd) Date: 2014-07-11 11:02
I've downloaded UBUNTU 12.04. I've compiled python3 and I got the same error.

Seleccionando el paquete sqlite3 previamente no seleccionado.
Desempaquetando sqlite3 (de .../sqlite3_3.7.9-2ubuntu1.1_i386.deb) ...
Procesando disparadores para man-db ...
Configurando libsqlite3-dev (3.7.9-2ubuntu1.1) ...
Configurando sqlite3 (3.7.9-2ubuntu1.1) ...
ubuntu@ubuntu:~$ python3.4 -c "import sqlite3"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.4/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.4/sqlite3/dbapi2.py", line 26, in <module>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'
msg222737 - (view) Author: Ismail Donmez (donmez) * Date: 2014-07-11 11:12
Chiming in here as a SUSE guy;

Can you make sure 

/usr/local/lib/python3.4/lib-dynload/_sqlite3.cpython-34m.so

does exist. If yes run ldd on it

ldd /usr/local/lib/python3.4/lib-dynload/_sqlite3.cpython-34m.so

And also give output of "which python3.4" to make sure you are running the right python instance.
msg222744 - (view) Author: Alejandro (alexganwd) Date: 2014-07-11 14:12
we have  /usr/local/lib/python3.4/lib-dynload/_sqlite3.cpython-34m.so but we didn't have it in /soft/pyt341/lib/python3.4/lib-dynload/

After copying it into /sofy/pyt341.... the problem was solved!! ;)

/soft/pyt341/bin/python3 -c "import sqlite3;print(sqlite3.sqlite_version)"
3.7.6.3

In my opinion running ./configure should check if sqlite libs are properly satisfied and break compilation if they aren't installed. 
:)

I don't know if this issue could be considered a bug. So I will close it as "works for me"

Thanks for all!
msg222745 - (view) Author: David (dpatino) Date: 2014-07-11 14:18
You're absolute right that file is not in path. 
However, in my view this a  bug, due to the fact libsqlite3-dev package must be installed before Python3.4.1 is compiled (or install it and recompile python) because there is no errors, no warnings... nothing.

In any case, thanks a lot for your help. This solution works for me.
msg223356 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-07-17 19:06
If the headers are missing, you will get a complaint at the end of the make process that it couldn't build the _sqlite module.  It should also have tried to import the sqlite3 module and complained if there was an error.  So, pre-install, everything looked fine to the build process.

Can you attach your 'make install' log?

(Berker: a key difference in your test is that OP specified an alternate --prefix)
msg223400 - (view) Author: Alejandro (alexganwd) Date: 2014-07-18 07:05
Here you have make_install.log

Thanks
msg223415 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-07-18 15:44
The install log shows the file being copied into place:

copying build/lib.linux-x86_64-3.4/_sqlite3.cpython-34m.so -> /soft/pyt341/lib/python3.4/lib-dynload

This does not line up with the fact that you said the file did not exist after the install.  Something would have to be deleting the file after it got copied into place.  After you run make install, is there anything at all in lib-dynload?
msg223416 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-07-18 15:47
configure with a prefix followed by make/make install works fine for me, by the way (on a Gentoo system).
msg322179 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-07-23 06:09
Closing this for now since we couldn't reproduce the problem and haven't heard back from the OP in a while.
History
Date User Action Args
2018-07-23 06:09:03berker.peksagsetstatus: open -> closed
type: behavior
messages: + msg322179

resolution: works for me
stage: resolved
2014-07-18 15:47:44r.david.murraysetmessages: + msg223416
2014-07-18 15:44:09r.david.murraysetmessages: + msg223415
2014-07-18 07:05:23alexganwdsetfiles: + make_install.log

messages: + msg223400
2014-07-17 19:06:45r.david.murraysetstatus: closed -> open
title: import sqlite3 not running -> import sqlite3 not running after configure --prefix=/alt/path; make; make install
nosy: + r.david.murray

messages: + msg223356

resolution: works for me -> (no value)
2014-07-11 14:18:53dpatinosetmessages: + msg222745
2014-07-11 14:12:36alexganwdsetstatus: open -> closed
resolution: works for me
messages: + msg222744
2014-07-11 12:21:39vstinnersetnosy: + vstinner
2014-07-11 11:12:31donmezsetnosy: + donmez
messages: + msg222737
2014-07-11 11:02:52alexganwdsetmessages: + msg222736
2014-07-11 09:46:59berker.peksagsetmessages: + msg222734
2014-07-11 09:13:07dpatinosetnosy: + dpatino
messages: + msg222733
2014-07-10 14:37:36alexganwdsetfiles: + make.log

messages: + msg222670
2014-07-10 14:24:01brett.cannonsetnosy: + brett.cannon
messages: + msg222668
2014-07-10 12:19:50alexganwdsetmessages: + msg222659
2014-07-10 12:04:50berker.peksagsettype: crash -> (no value)

messages: + msg222657
nosy: + berker.peksag
2014-07-10 10:00:36alexganwdcreate