nais inpoh gan
nais inpoh gan

Reputation: 3379

Setup Cassandra for Django - "ImportError: No module named pycassa"

I've followed this guide: https://github.com/ericflo/twissandra

Pycassa has been installed including all the dependencies. everything running smoothly, but running python manage.py sync_cassandra give message:

ImportError: No module named pycassa

So I running Python interactive interpreter and typing import pycassa and that command runs successfully, with no errors.

Running

import sys
sys.path

will give message:

['', '/home/z/twiss/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg', '/home/z/twiss/lib/python2.6/site-packages/pip-0.8.2-py2.6.egg', '/home/z/twiss/lib/python2.6', '/home/z/twiss/lib/python2.6/plat-linux2', '/home/z/twiss/lib/python2.6/lib-tk', '/home/z/twiss/lib/python2.6/lib-old', '/home/z/twiss/lib/python2.6/lib-dynload', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/home/z/twiss/lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages/pycassa-1.0.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.1-py2.6.egg', '/usr/local/lib/python2.6/site-packages', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0']

the site-packages is in the list. but I a bit confused because this is in virtual environment

I dont know what happened and what to do

Upvotes: 2

Views: 1500

Answers (2)

Gajen Sunthara
Gajen Sunthara

Reputation: 4818

Probably pycassa package is missing, I would try the following and also recommend storing the necessary packages in a requirements file and leverage freeze/install like this.

To solve the first issue with pycassa error:

pip install pycassa

enter image description here

Once all the requirements are in for your python project, output the required packages into requirements.txt like the package.json for NodeJS.

  • freeze: output current packages into the requirements.txt file
  • Install: install every needed packages from the requirements.txt into Python environment
pip freeze > requirements.txt
pip install -r requirements.txt

Upvotes: 0

Tyler Hobbs
Tyler Hobbs

Reputation: 6932

Try editing tweets/management/commands/sync_cassandra.py to include

import sys
print sys.path

at the top. Make sure this includes the directory that pycassa is in. For example, I have a pycassa directory in twiss/lib/python2.6/site-packages.

By the way, ericflo's repo is out of date -- you'll want to use this version until he accepts some pull requests.

Upvotes: 2

Related Questions