import sqlite3 generates:
Unused import: sqlite3
Unresolved import: sqlite3
sqlite3 Found at: DatabaseTests
import sqlite3
However, this works perfectly in the terminal when using the python command-line.
I am running on a Mac Mountain Lion, with the default installation of Python. I am using PyDev in Eclipse Indigo.
I have the same development environment and suffered from the same issue. I have resolved it by
- switching to the MacPorts Python,
- by only using packages that I install from that project
- and by setting the default Python interpreter on Eclipse-Pydev to be the MacPorts executable
This works perfectly for me, with the one hitch that I still sometimes get an Unresolved import
warning, but if the package is installed, my script still runs.
This is a very old thread but I don't see the solution I found for this problem so I'll post it in hopes that somebody sees this and can then solve the problem:
you need to add 'sqlite3' (without the quotatios) in the 'forced builtins' tab in Window>Preferences>PyDev>Python Interpreter
I fixed this by adding _sqlite3 (note the underscore) to the Forced Built-ins in Window>Preferences>PyDev>Interpreters>Python Interpreter.
Looks like the project references do not have the site-package path added. Try adding the path to sqlite3 (/usr/lib/python2.7/sqlite3/ or the path installed to which you can get from python shell) to project references from Project -> Properties -> Pydev-PYTHOPATH -> External libraries.
I had a similar problem with other imports (simplejson and matplotlib).
I'm working on Ubuntu and the problems with the imports started after upgrading from Ubuntu 11.10 to 12.04 (which also upgraded the python version and the eclipse).
My steps for solving the problem were:
- In the terminal, do 'import sys' then 'print sys.executable'. This gives the path to the current interpreter.
- In Eclipse - Window->preferences->PyDev->interpreter-python. Remove the old path and add the path retrieved in stage 1.
- In the problematic project go to Project->properties->PyDev-PYHTONPATH, the external libraries tab remove old paths and add the correct ones (on Ubuntu one can find it via the synaptic manager, e.g. for simplejson go to the synaptic manager, type simplejson in the search box, mark the right result right-click and choose properties from the menu then choose the 'installed files' tab to see the path for the installed files.
I hope someone will find it useful.