3

I am trying to import nltk in my python file but i am getting this error

File "mycode.py", line 5, in
from utilities import TextCleaner, TF_IDF_FeatureExtraction File "/home/myhome/Baseline/utilities.py", line 1, in import nltk File "/home/myhome/.local/lib64/python3.5/site-packages/nltk/init.py", line 152, in from nltk.stem import * File "/home/myhome/.local/lib64/python3.5/site-packages/nltk/stem/init.py", line 29, in from nltk.corpus.reader.panlex_lite import *
File "/home/myhome/.local/lib64/python3.5/site-packages/nltk/corpus/reader/panlex_lite.py", line 15, in

import sqlite3 ImportError: No module named 'sqlite3'

The python version on server is 3.5.3 and i have sqlite version 3.13.0 installed i am currently running code on remote server and i cant use sudo command since its restricted for remote users. is there any thing i can do without sudo command to solve this problem?

Community
  • 1
  • 1
Umer iqbal
  • 196
  • 1
  • 2
  • 15
  • Did the sqlite3 was installed after compiling python? – Grzegorz Bokota Mar 14 '19 at 20:38
  • no idea . i recently got the remote access. the resource is placed somewhere else i have no idea how the python was installed. can you describe the exact issue so i can request administrators – Umer iqbal Mar 14 '19 at 20:40
  • I meet similar problem when I install python from source on machine where there is no headers for sqlite (even when sqlite as tool was installed). After instalin needed package I need to reinstall python (recompile). – Grzegorz Bokota Mar 14 '19 at 20:45

3 Answers3

3

I Solved this issue by commenting out import sqlite3 in the panlex_lite.py file present inside nltk library folder and also commented out sqlite3 connection string present inside this file and the code works now. This solution will only work if you are intented to use nltk only but not sqlite3

Umer iqbal
  • 196
  • 1
  • 2
  • 15
1

What you have installed on server, is not a python module, but the sqlite3 utility. If you have pip3 installed, you can run pip3 install pysqlite3 from user, so it will install the module sqlite3 in your home directory.

Michael
  • 5,095
  • 2
  • 13
  • 35
0

I assume by commenting out the import sqlite3 you are not allowing it to use the module, The issue is that the version of SQLite including with the OS is old. I have already highlighted the solution at the following discussion: No module named _sqlite3

You can find as well my blog post on the topic at: http://www.virtualizationteam.com/cloud/running-vcd-cli-fail-with-the-following-error-modulenotfounderror-no-module-named-_sqlite3.html