English 中文(简体)
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

问题回答

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.

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




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签