Bootcamp: Installing in windows

Created on 19 Dec 2017  ·  14Comments  ·  Source: vitorfs/bootcamp

Hi,

I installed in my windows pc but I have this error:

python manage.py migrate

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 347, in execute
    django.setup()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\allan\Documents\progetti\bootcamp\bootcamp\activities\models.py", line 14, in <module>
    class Activity(models.Model):
  File "C:\Users\allan\Documents\progetti\bootcamp\bootcamp\activities\models.py", line 26, in Activity
    user = models.ForeignKey(User)

TypeError: __init__() missing 1 required positional argument: 'on_delete'

image

image

I want to help with some feature when I have lost time.

Support help wanted question

All 14 comments

This error takes place when django==2.0, at this moment Bootcamp is not compatible with that version of Django. Please remove it and install a previous version, django==1.11.x works correctly.

Good morning @sebastian-code ,

I have downgrage the django, but now I have this error:

Traceback (most recent call last):
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
    conn = Database.connect(**conn_params)
sqlite3.OperationalError: unable to open database file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\migrate.py", line 83, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
    self.build_graph()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 209, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 52, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 254, in cursor
    return self._cursor()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 229, in _cursor
    self.ensure_connection()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
    conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file

image

Hi @Allan-Nava it appears you have issues with your database and the server is unable to establish connection with the data volume, how are you doing that part?

Hi @sebastian-code, is my first django app with my personal pc windows. What should I do?

It depends how you work with databases. Personally I use Docker, but you could use a local instance of PostgreSQL, perhaps mount a networked DB server, or a VM of some sorts. There is also the easier option than is using SQLite locally.

I want to try use SQLite Locally

For that define the DATABASE_URL variable inside your .env file with a properly formated SQLite database address using URL format. You can find an example inside the env.example file.

I use the .env with the same conf:

# PostgreSQL conf
# POSTGRES_PASSWORD=mysecretpass
# POSTGRES_USER=my_super_user
# POSTGRES_DB=bootcamp
# DATABASE_URL=postgresql://my_super_user:[email protected]:5432/bootcamp

# Main environmental variables
DEBUG=True
SECRET_KEY=s3cr3t_key
ALLOWED_HOSTS=*
# URL to have SQLite example and to pass TravisCI
DATABASE_URL=sqlite:////bootcamp/db.sqlite3
# URL for Redis
# REDIS_URL=redis://redis_ip_address:port

I have the same error:

C:\Users\allan\Documents\progetti\bootcamp>python manage.py migrate
Traceback (most recent call last):
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
    conn = Database.connect(**conn_params)
sqlite3.OperationalError: unable to open database file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\migrate.py", line 83, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
    self.build_graph()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 209, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 52, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 254, in cursor
    return self._cursor()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 229, in _cursor
    self.ensure_connection()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
    conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file

image

That is because the address is the wrong way. For SQLite, Django requires the physical location for the SQLite file inside your hard drive, expressed in URI format.

@sebastian-code Thank's, it works!

image

How do you use django 1.11 with this command pip install -U -r requirements/local.txt

I solved thanks!

2018-01-12 11:17 GMT+01:00 jackengine notifications@github.com:

How do you use django 1.11 with this command pip install -U -r
requirements/local.txt


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/vitorfs/bootcamp/issues/138#issuecomment-357199201,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AVdMg5tftf9BMLRv8opKHg_ngou7E-Zpks5tJzE2gaJpZM4RHiIY
.

@sebastian-code I have django 2.x in pip cache. Now how I can force pip to use django 1.9 while running this command pip install -U -r requirements/local.txt

Hi @jackengine The easiest way is to execute the command, and once installed, manually delete the package, and then install django again, but declaring the specific versión you want. My advice would be not going with django v1.9, is too old, I would suggest to use django 1.11 which is LTS.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Allan-Nava picture Allan-Nava  ·  9Comments

mwanjajoel picture mwanjajoel  ·  5Comments

phamminhtris picture phamminhtris  ·  12Comments

Shekharnunia picture Shekharnunia  ·  6Comments

sebastian-code picture sebastian-code  ·  11Comments