HumanDynamics / openPDS

openpds.media.mit.edu
MIT License
110 stars 33 forks source link

manage.py syncdb troubles on osx #13

Closed qyn6 closed 9 years ago

qyn6 commented 9 years ago

I'm getting this error when running syncdb (on Mac)

No idea what's going on with it. All of the requirements, databases, etc are installed. Any ideas, @brian717 ?

File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/core/management/init.py", line 443, in execute_from_command_line utility.execute() File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/core/management/init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(_args, _options.dict) File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(_args, _options) File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle return self.handle_noargs(options) File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs cursor = connection.cursor() File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/db/backends/init.py", line 319, in cursor cursor = util.CursorWrapper(self._cursor(), self) File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 288, in _cursor self._sqlite_create_connection() File "/Users/jbt/Documents/code/pdsEnv/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 278, in _sqlite_create_connection self.connection = Database.connect(kwargs) sqlite3.OperationalError: unable to open database file

brian717 commented 9 years ago

Does the user running syncdb have write access to the parent directory for the sqlite database? This is required in order to use sqlite as the Django ORM backend.

RogerTangos commented 9 years ago

I pushed an update that resolves the issue. The trouble is that in settings.py the database name is

DATABASES = {
   ...
        'NAME': '/openPDS/openpds/test.db',                      # Or path to database file if using sqlite3.
   ...
}

name should be

 'NAME': 'test.db', 

There was a similar problem in wsgi.templates, which is now fixed. @brian717 - is it working for you as well?

brian717 commented 9 years ago

This will pose an issue with apache and other web servers, which require an absolute path, rather than a relative one. The absolute path can work with both, provided that permissions are set up properly. On Oct 10, 2014 10:29 AM, "RogerTangos" notifications@github.com wrote:

I pushed an update that resolves the issue. The trouble is that in settings.py the database name is

DATABASES = { ... 'NAME': '/openPDS/openpds/test.db', # Or path to database file if using sqlite3. ... }```

name should be

'NAME': 'test.db',

There was a similar problem in wsgi.templates, which is now fixed. @brian717 - is it working for you as well?

— Reply to this email directly or view it on GitHub https://github.com/HumanDynamics/openPDS/issues/13#issuecomment-58663317 .

qyn6 commented 9 years ago

I got it working by putting an absolute path in settings.

brian717 commented 9 years ago

Glad to hear it! Incidentally, did you use the setup script to generate settings.py? On Oct 10, 2014 10:39 AM, "qyn6" notifications@github.com wrote:

I got it working by putting an absolute path in settings.

— Reply to this email directly or view it on GitHub https://github.com/HumanDynamics/openPDS/issues/13#issuecomment-58664641 .

qyn6 commented 9 years ago

Yes, however it didn't generate test.db and I had to get the file separately form Albert.

RogerTangos commented 9 years ago

Hrmph. I didn't realize that that would be a problem. The script is generating settings.py and is producing test.db

For absolute paths, will this work in settings.py? and will additional changes be necessary in wsgi.py?

PWD = os.path.dirname(os.path.realpath(__file__ ))

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': os.path.join(PWD, 'test.db'),                      # Or path to database file if using sqlite3.
        'USER': 'test',                      # Not used with sqlite3.
        'PASSWORD': 'test',                  # 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.
    }
brian717 commented 9 years ago

The setup file uses the current working directory as a default if one isn't provided (this the first prompt). This is the directory used in both wsgi.py and additions l settings.py. Are we seeing other behavior?

Hrmph. I didn't realize that that would be a problem. The script is generating settings.py and is producing test.db

For absolute paths, will this work in settings.py? and will additional changes be necessary in wsgi.py?

PWD = os.path.dirname(os.path.realpath(file ))

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': os.path.join(PWD, 'test.db'), # Or path to database file if using sqlite3. 'USER': 'test', # Not used with sqlite3. 'PASSWORD': 'test', # 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. }

— Reply to this email directly or view it on GitHub https://github.com/HumanDynamics/openPDS/issues/13#issuecomment-58669072.

brian717 commented 9 years ago

I believe the setup.py file should be spitting out instructions to run ./manage.py syncdb after setup is complete - this is the command that eventually creates the test.db database. There should be no need to copy this file across installs.

RogerTangos commented 9 years ago

This is resolved in the dev 522a92624d2b45be40fc45ecc2db3edd8e8e33b4.