Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yhamoudi opened this issue Dec 23, 2014 · 11 comments
Closed

Comments

@yhamoudi
Copy link

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
Copy link
Member

rspeer commented Dec 30, 2014

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

@yhamoudi
Copy link
Author

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
Copy link
Member

rspeer commented Dec 30, 2014

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.

@rspeer rspeer closed this as completed Dec 30, 2014
@yhamoudi
Copy link
Author

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
Copy link

arj-196 commented Dec 15, 2015

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 #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
Copy link
Member

rspeer commented Dec 15, 2015

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
Copy link

arj-196 commented Dec 16, 2015

Awesome thank you @rspeer. That solved the problem

@fdmsouza
Copy link

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
Copy link

fdmsouza commented May 26, 2016

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
Copy link

mosynaq commented Jul 4, 2016

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
Copy link
Member

rspeer commented Jul 5, 2016

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
#33 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAOS8xYquv4MNLrIRvhFzavXBNC-tMZyks5qSS1cgaJpZM4DLqvD
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants