• Home
  • About
  • Contact
  • Store

IT from Scratch

Small Business IT from the ground up

Python Error: No Module Named Solr

May 6, 2013 By The New Guy Leave a Comment

Error: No module named solrApache SolrI’ve been trying to get this open source document repository system Invenio installed for the boss but today I ran into another problem:

Error: No module named solr

It turns out it wasn’t a problem peculiar to Invenio. Any Python script anywhere trying to import solr was getting this error. Yet once again, there’s an easy solution.

InvenioInvenio’s Full-Text Search

You may have come across this error through a different means, but I ran into it while attempting to install and configure Invenio. One of the cool features of this document repository system is its ability to support full-text search.

But Invenio doesn’t do the searching itself. It hooks up with Apache Solr to handle the task.

pythonPython and Solr

Invenio is just a collection of Python scripts. So when Invenio tries to import solr in bibindex_engine.py, it’s not Invenio that’s trying to find Solr — it’s Python.

I discovered that this was not an Invenio issue when I opened up an interactive Python shell. I tried to import solr from the shell and got the same error: no module named solr.

After looking around for a while, I finally figured out that though Python and Solr where both installed, Solr no longer comes packaged with a client for Python to access it.

All you need to do to fix this problem is install a Python Solr client:

$ sudo easy_install solrpy
Searching for solrpy
Reading http://pypi.python.org/simple/solrpy/
Reading http://code.google.com/p/solrp
Reading http://code.google.com/p/solrpy
Best match: solrpy 0.9.5
Downloading http://pypi.python.org/packages/source/s/solrpy/solrpy-0.9.5.tar.gz#md5=d044b7ab09b362ccef7bd168542b28c1
Processing solrpy-0.9.5.tar.gz
Writing /tmp/easy_install-5th84f/solrpy-0.9.5/setup.cfg
Running solrpy-0.9.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-5th84f/solrpy-0.9.5/egg-dist-tmp-fINTfU
warning: no previously-included files matching '*.pyo' found anywhere in distribution
zip_safe flag not set; analyzing archive contents...
Adding solrpy 0.9.5 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/solrpy-0.9.5-py2.7.egg
Processing dependencies for solrpy
Finished processing dependencies for solrpy

And that’s it. Your Python can now import solr like a pro.

Filed Under: Scratch

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Click Here for 500 MB free VPN connection through Private Tunnel

Recent Posts

  • How to Get the macOS Catalina Installer, Post Big Sur
  • Mac: How to Get SHA1 Hash
  • iTunes error: “You do not have enough access privileges for this operation”
  • Is Websense Filtering My Internet Traffic?
  • How to Delete a Mac VPN Profile
  • Home
  • About
  • Contact
  • Store

Copyright © 2025 ·WP-Ubuntu