# Sqlite3 on Python3 fails



## baddestpoet (Sep 5, 2015)

Hi,

I've been trying to fix this issue for about a day now, with no luck. Trying to use the sqlite3 module with python3(4):



```
Python 3.4.3 (default, Sep  4 2015, 20:49:55)
[GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] on freebsd10
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", 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 27, in <module>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'
```

Searching for sqlite3:


```
root@redacted:~ # find / -name "sqlite3"
/tmp/npm-83738-9b522bdf/registry.npmjs.org/sqlite3
/usr/ports/security/node_modules/sqlite3
/usr/ports/databases/sqlite3
/usr/local/bin/sqlite3
/usr/local/lib/python2.7/sqlite3
/usr/local/lib/python3.4/sqlite3
```

Installing 
	
	



```
/usr/ports/databases/py-sqlite3
```
 installs 
	
	



```
py27-sqlite3-2.7.10_6
```
 which is for python 2.7....

Anybody have any fix for this? 

Much appreciated.


----------



## tobik@ (Sep 5, 2015)

In /usr/ports/databases/py-sqlite3 run

```
make PYTHON_VERSION=python3.4 install
```


----------



## baddestpoet (Sep 5, 2015)

tobik said:


> In /usr/ports/databases/py-sqlite3 run
> 
> ```
> make PYTHON_VERSION=python3.4 install
> ```



Thanks for the answer.


```
root@redacted:/usr/ports/databases/py-sqlite3 # make PYTHON_VERSION=python3.4 install
===>  Staging for py34-sqlite3-3.4.3_6
===>   py34-sqlite3-3.4.3_6 depends on package: py34-setuptools34>0 - found
===>   py34-sqlite3-3.4.3_6 depends on file: /usr/local/bin/python3.4 - found
===>   py34-sqlite3-3.4.3_6 depends on shared library: libsqlite3.so - found (/usr/local/lib/libsqlite3.so)
===>   Generating temporary packing list
cd: /usr/ports/databases/py-sqlite3/work/Python-3.4.3/Modules: No such file or directory
*** Error code 2

Stop.
make: stopped in /usr/ports/databases/py-sqlite3
```


----------



## tobik@ (Sep 5, 2015)

Run `make clean` first.


----------



## baddestpoet (Sep 5, 2015)

tobik said:


> Run `make clean` first.



That worked, cheers!


----------

