sqlite in 2.7 on redhat 6

Larry Martell larry.martell at gmail.com
Thu Jun 15 13:22:42 EDT 2017


On Thu, Jun 15, 2017 at 12:20 PM, Kushal Kumaran <kushal at locationd.net> wrote:
> Larry Martell <larry.martell at gmail.com> writes:
>
>> On Thu, Jun 15, 2017 at 10:35 AM, Peter Otten <__peter__ at web.de> wrote:
>>> Larry Martell wrote:
>>>
>>>>> On linux the system sqlite3 is used.
>>>>
>>>> I tried building and installing sqlite from source and that did not
>>>> solve the problem.
>>>
>>> You misunderstood: the problem is not sqlite3 it's that python needs
>>> sqlite3's header files.
>>>
>>>>> Is that a Python version that you compiled yourself?
>>>>
>>>> No I installed it with pip install python2.7
>>>
>>> I'd never have thought of trying that -- but still: did that download binary
>>> blobs or did it invoke the C compiler?
>>
>> Sorry I mistyped - it wasn't pip it was yum.
>>
>
> Are you sure that is the python you are running?  The python provided by
> the OS repositories would have installed python at /usr/bin/python
> (possibly with additional names such as /usr/bin/python2.7).  The
> exception you posted earlier is looking at files in /usr/local and
> /opt/rh, neither of which would be searched by the system-installed
> python by default.
>
> It is possible (likely?) that /usr/local/bin is earlier in your $PATH
> than /usr/bin, which is resulting in some /usr/local/bin/python
> shadowing the system python.  If so, run the system python with an
> absolute path like /usr/bin/python and see if you are able to import
> sqlite3.

/usr/bin/python2.7 is a symlink to /usr/local/bin/python2.7:

$ ls -l /usr/bin/python2.7

lrwxrwxrwx. 1 root root 24 Apr 22  2016 /usr/bin/python2.7 ->
/usr/local/bin/python2.7

On Redhat 6 the system python is 2.6. You cannot change that as it breaks yum.

/usr/local/bin/ is earlier in my path then /usr/bin. But I used
python2.7 all the time here and other packages work fine.

What led me down this rabbit hole was that I am trying to use
pypolibox and that is failing with this traceback:

Traceback (most recent call last):
  File "/usr/local/bin/pypolibox", line 9, in <module>
    load_entry_point('pypolibox==1.0.2', 'console_scripts', 'pypolibox')()
  File "/usr/local/lib/python2.7/site-packages/distribute-0.6.35-py2.7.egg/pkg_resources.py",
line 343, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/site-packages/distribute-0.6.35-py2.7.egg/pkg_resources.py",
line 2309, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/site-packages/distribute-0.6.35-py2.7.egg/pkg_resources.py",
line 2015, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/local/lib/python2.7/site-packages/pypolibox/pypolibox.py",
line 13, in <module>
    from nltk.featstruct import Feature
  File "/usr/local/lib/python2.7/site-packages/nltk/__init__.py", line
137, in <module>
    from nltk.stem import *
  File "/usr/local/lib/python2.7/site-packages/nltk/stem/__init__.py",
line 29, in <module>
    from nltk.stem.snowball import SnowballStemmer
  File "/usr/local/lib/python2.7/site-packages/nltk/stem/snowball.py",
line 26, in <module>
    from nltk.corpus import stopwords
  File "/usr/local/lib/python2.7/site-packages/nltk/corpus/__init__.py",
line 66, in <module>
    from nltk.corpus.reader import *
  File "/usr/local/lib/python2.7/site-packages/nltk/corpus/reader/__init__.py",
line 105, in <module>
    from nltk.corpus.reader.panlex_lite import *
  File "/usr/local/lib/python2.7/site-packages/nltk/corpus/reader/panlex_lite.py",
line 15, in <module>
    import sqlite3
  File "/usr/local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3



More information about the Python-list mailing list