commonsense / conceptnet5

Code for building ConceptNet from raw data.
Other
2.75k stars 352 forks source link

Run the example: sqlite3.OperationalError: unable to open database file #33

Closed yhamoudi closed 9 years ago

yhamoudi commented 9 years ago

Hi,

I have followed all the instructions here: https://github.com/commonsense/conceptnet5/wiki/Running-your-own-copy and i try to run the example:

>>> from conceptnet5.query import lookup
>>> for assertion in lookup('/c/en/example'):
...     print(assertion)

However, i get the following error:

  File "<stdin>", line 1, in <module>
  File "/home/yassine/conceptnet5/conceptnet5/query.py", line 74, in lookup
    self.load_index()
  File "/home/yassine/conceptnet5/conceptnet5/query.py", line 57, in load_index
    self._db_filename, self._edge_dir, self.nshards
  File "/home/yassine/conceptnet5/conceptnet5/formats/sql.py", line 210, in __init__
    self._connect()
  File "/home/yassine/conceptnet5/conceptnet5/formats/sql.py", line 215, in _connect
    self.dbs[i] = sqlite3.connect(filename)
sqlite3.OperationalError: unable to open database file

Does anyone know how to fix it? Thanks :)

rspeer commented 9 years ago

Which set of instructions did you follow? What was the output?

yhamoudi commented 9 years ago

I followed the "The high-bandwidth, low-computation way":

git clone https://github.com/commonsense/conceptnet5
pyvenv-3.4 conceptnet-env
source conceptnet-env/bin/activate
cd conceptnet5
python setup.py develop
make download_db

All these instructions run fine (no error messages output).

rspeer commented 9 years ago

Okay, I get it. I left out a step. You either need to set the CONCEPTNET_DATA environment variable to be the full path to the data/ directory, or you need to symbolic link the data/ directory to .conceptnet5 under your home directory. I'd choose the second way, because it's more convenient:

ln -s `readlink -f data` ~/.conceptnet5

I'll add that to the instructions.

yhamoudi commented 9 years ago

I tried (from the directory containing conceptnet5 folder) :

ln -s `readlink -f data` ~/.conceptnet5

But it didn't work (same error message when i try to run the example). my bad, this operation must be performed into conceptnet5 folder

the following code also solved the problem:

CONCEPTNET_DATA=~/conceptnet5/data/
export CONCEPTNET_DATA

Thank you :)

arj-196 commented 8 years ago

I am trying to install conceptnet locally on a mac.

I took The high-bandwidth, low-computation way https://github.com/commonsense/conceptnet5/wiki/Running-your-own-copy and did the following:

git clone https://github.com/commonsense/conceptnet5
pyvenv-3.4 conceptnet-env
source conceptnet-env/bin/activate
cd conceptnet5
python setup.py develop
make download_db

Then at the last step i am getting the following error :

command

ln -s `readlink -f data` ~/.conceptnet5

output

readlink: illegal option -- f
usage: readlink [-n] [file ...]

So i did ignored this step, because i had seen a google discussion which proposed another method (as the link command was not working for me)

So from this discussion https://github.com/commonsense/conceptnet5/issues/33 I tried the following :

CONCEPTNET_DATA=~/conceptnet5/data/
export CONCEPTNET_DATA

But this didnt work, cause when doing the following :

from conceptnet5.query import lookup
lookup('/c/en/examples')

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/query.py", line 75, in lookup
    self.load_index()
  File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/query.py", line 58, in load_index
    self._db_filename, self._edge_dir, self.nshards
  File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/formats/sql.py", line 211, in __init__
    self._connect()
  File "/Users/arj/Desktop/app/conceptnet5/conceptnet5/formats/sql.py", line 216, in _connect
    self.dbs[i] = sqlite3.connect(filename)
sqlite3.OperationalError: unable to open database file

What should be the OS equivalent of the ln command?

Or what else can i do for conceptnet to locate the database file ?

rspeer commented 8 years ago

I didn't know that readlink -f was a Linux-specific flag. It also looks like it should be unnecessary, so I plan to remove the -f so it'll work on Mac too.

As for your new problem, I think I see the solution: Python doesn't inherently know that ~ means your home directory. If you replace that with the actual path to your home directory, I think that should work.

arj-196 commented 8 years ago

Awesome thank you @rspeer. That solved the problem

fdmsouza commented 8 years ago

I've tried what has been suggested here, both creating the symbolic link and setting the the environment variable CONCEPTNET but none worked. I keep getting the following error:

`enb221-lp1:~ fsouza$ python Python 3.5.0 |Anaconda 2.4.0 (x86_64)| (default, Oct 20 2015, 14:39:26) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type "help", "copyright", "credits" or "license" for more information.

from conceptnet5.query import lookup for assertion in lookup('/c/en/example'): ... print(assertion) ... Traceback (most recent call last): File "", line 1, in File "/Users/fsouza/Google Drive/PhD/ConceptNet5/conceptnet5/conceptnet5/query.py", line 75, in lookup self.load_index() File "/Users/fsouza/Google Drive/PhD/ConceptNet5/conceptnet5/conceptnet5/query.py", line 58, in load_index self._db_filename, self._edge_dir, self.nshards File "/Users/fsouza/Google Drive/PhD/ConceptNet5/conceptnet5/conceptnet5/formats/sql.py", line 211, in init self._connect() File "/Users/fsouza/Google Drive/PhD/ConceptNet5/conceptnet5/conceptnet5/formats/sql.py", line 216, in _connect self.dbs[i] = sqlite3.connect(filename) sqlite3.OperationalError: unable to open database file`

Any other ideas?

fdmsouza commented 8 years ago

The problem was resolved by getting the database through the "low bandwidth, high computational way" method:

cd conceptnet5 make apsw make download_assertions build_db

Hopefully, this will be useful for others that run into the same issue.

Cheers!

mosynaq commented 8 years ago

I want to run ConceptNet locally on Windows 7. I followed "The high-bandwidth, low-computation way". I extracted the file "conceptnet5_db_5.4.tar.bz2" I got two folders: assertions and db. I moved the folders into many paths but running the below code gives me the same error.

The code:

from conceptnet5.query import lookup
lookup('/c/en/examples')

The error:

(PATH_TO_PYTHON_VIRTUAL_ENV)\python.exe (PATH_TO_CODE_IN_PYTHON)/MainPy34.py
Traceback (most recent call last):
  File "(PATH_TO_CODE_IN_PYTHON)/MainPy34.py", line 2, in <module>
    for assertion in lookup('/c/en/example'):
  File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\query.py", line 75, in lookup
    self.load_index()
  File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\query.py", line 58, in load_index
    self._db_filename, self._edge_dir, self.nshards
  File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\formats\sql.py", line 211, in __init__
    self._connect()
  File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\formats\sql.py", line 216, in _connect
    self.dbs[i] = sqlite3.connect(filename)
sqlite3.OperationalError: unable to open database file
rspeer commented 8 years ago

You can set your CONCEPTNET_DATA environment variable to the path that contains the 'assertions' and 'db' folders.

On Mon, 4 Jul 2016 at 11:57 mosynaq notifications@github.com wrote:

I want to run ConceptNet locally on Windows 7. I followed "The high-bandwidth, low-computation way". I extracted the file "conceptnet5_db_5.4.tar.bz2" i got two folders. I moved the folders into many paths but running the below code givesme the same error. the code:

from conceptnet5.query import lookup lookup('/c/en/examples')

The error: (PATH_TO_PYTHON_VIRTUAL_ENV)\python.exe (PATH_TO_CODE_IN_PYTHON)/MainPy34.py

Traceback (most recent call last):

File "(PATH_TO_CODE_IN_PYTHON)/MainPy34.py", line 2, in

for assertion in lookup('/c/en/example'):

File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\query.py", line 75, in lookup self.load_index() File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\query.py", line 58, in load_index self._db_filename, self._edge_dir, self.nshards File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\formats\sql.py", line 211, in init self._connect() File "(PATH_TO_PYTHON_VIRTUAL_ENV)\lib\site-packages\conceptnet5\formats\sql.py", line 216, in _connect

self.dbs[i] = sqlite3.connect(filename) sqlite3.OperationalError: unable to open database file

You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/commonsense/conceptnet5/issues/33#issuecomment-230318965, or mute the thread https://github.com/notifications/unsubscribe/AAOS8xYquv4MNLrIRvhFzavXBNC-tMZyks5qSS1cgaJpZM4DLqvD .