Pages

Showing posts with label Errors. Show all posts
Showing posts with label Errors. Show all posts

Friday, March 15, 2013

sqlite3.OperationalError: unable to open database file

I'm a beginner, too, and had a similar problem. The .db file will created for you when you run python manage.py syncdb. From your terminal window, just be sure that you're located in the same folder as the manage.py file in your directory structure. From this location, I was able to successfully create the necessary tables. The settings.py file will have already been created when you initially set the project up.


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'mydata.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

Database will be created once you do python manage.py syncdb

Finally to check if everything is fine

from django.db import connection
cursor = connection.cursor()

If nothing happens, then your database is configured properly. Otherwise, check the error message for clues about what's wrong.

Friday, October 5, 2012

Saving your LSI model in gensim


A description of errors and the code, and finally what worked. I think it was just a silly mistake. I was accessing the npy file whereas the normal pkl file access worked.

Error
LSI
Traceback (most recent call last):
  File "tutorial1.py", line 85, in <module>
    lsi.load('tmp/lsa_model.pkl.npy')

Code 
#lsi = models.LsiModel(corpus, id2word = dictionary, num_topics =6)
print "\nLSI"
#lsi.save('tmp/lsa_model.pkl')
lsi = models.LsiModel.load('tmp/lsa_model.pkl.npy')

Error
Traceback (most recent call last):
  File "tutorial1.py", line 86, in <module>
    lsi = models.LsiModel.load('tmp/lsa_model.pkl.npy')
  File "/usr/local/lib/python2.7/dist-packages/gensim-0.8.6-py2.7.egg/gensim/models/lsimodel.py", line 533, in load
    result = utils.unpickle(fname)
  File "/usr/local/lib/python2.7/dist-packages/gensim-0.8.6-py2.7.egg/gensim/utils.py", line 492, in unpickle
    return cPickle.load(open(fname, 'rb'))
cPickle.UnpicklingError: invalid load key, '�'.

But finally this worked:

#lsi = models.LsiModel(corpus, id2word = dictionary, num_topics =6)
print "\nLSI"
#lsi.save('tmp/lsa_model.pkl')
lsi = models.LsiModel.load('tmp/lsa_model.pkl')

So finally this is what worked:

Saving the LSA:

lsi = models.LsiModel(corpus, id2word = dictionary, num_topics =6)
print "\nLSI"
lsi.save('tmp/lsa_model2.pkl')
#lsi = models.LsiModel.load('tmp/lsa_model.pkl')

Loading the LSA:

#lsi = models.LsiModel(corpus, id2word = dictionary, num_topics =6)
print "\nLSI"
#lsi.save('tmp/lsa_model2.pkl')
lsi = models.LsiModel.load('tmp/lsa_model2.pkl')

Thursday, August 18, 2011

Java NoClassDefFoundError

In your Java Web project make sure you add the jar files to WEB-INF/lib and make sure that you remove the external jar files from your build path. Instead of adding them as external jar files just add them to the lib folder and save yourself the ClassDefNotFound errors which are very irritating.