brightway-lca / brightway2-io

Importing and exporting for the Brightway LCA framework
BSD 3-Clause "New" or "Revised" License
26 stars 41 forks source link

Creating a new project #127

Closed gamboamm closed 1 year ago

gamboamm commented 2 years ago

For the last few years I have used brightway and AB without any problems. However, this week I have installed both on a new pc and when trying to create a new project (using jupyter notebook):

bw2.projects.create_project('Mario')

I get the following error message:

IntegrityError                            Traceback (most recent call last)
File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:3177, in Database.execute_sql(self, sql, params, commit)
   3176 try:
-> 3177     cursor.execute(sql, params or ())
   3178 except Exception:

IntegrityError: NOT NULL constraint failed: projectdataset.full_hash

During handling of the above exception, another exception occurred:

IntegrityError                            Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 bw2.projects.create_project('Mario')

File ~\Miniconda3\envs\bw2\lib\site-packages\bw2data\project.py:214, in ProjectManager.create_project(self, name, **kwargs)
    211 name = name or self.current
    212 if not ProjectDataset.select().where(
    213         ProjectDataset.name == name).count():
--> 214     ProjectDataset.create(
    215         data=kwargs,
    216         name=name
    217     )
    218 create_dir(self.dir)
    219 for dir_name in self._basic_directories:

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:6430, in Model.create(cls, **query)
   6427 @classmethod
   6428 def create(cls, **query):
   6429     inst = cls(**query)
-> 6430     inst.save(force_insert=True)
   6431     return inst

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:6640, in Model.save(self, force_insert, only)
   6638     rows = self.update(**field_dict).where(self._pk_expr()).execute()
   6639 elif pk_field is not None:
-> 6640     pk = self.insert(**field_dict).execute()
   6641     if pk is not None and (self._meta.auto_increment or
   6642                            pk_value is None):
   6643         self._pk = pk

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:1918, in database_required.<locals>.inner(self, database, *args, **kwargs)
   1915 if not database:
   1916     raise InterfaceError('Query must be bound to a database in order '
   1917                          'to call "%s".' % method.__name__)
-> 1918 return method(self, database, *args, **kwargs)

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:1989, in BaseQuery.execute(self, database)
   1987 @database_required
   1988 def execute(self, database):
-> 1989     return self._execute(database)

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:2778, in Insert._execute(self, database)
   2776     self._returning = (self.table._primary_key,)
   2777 try:
-> 2778     return super(Insert, self)._execute(database)
   2779 except self.DefaultValuesException:
   2780     pass

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:2496, in _WriteQuery._execute(self, database)
   2494     cursor = self.execute_returning(database)
   2495 else:
-> 2496     cursor = database.execute(self)
   2497 return self.handle_result(database, cursor)

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:3190, in Database.execute(self, query, commit, **context_options)
   3188 ctx = self.get_sql_context(**context_options)
   3189 sql, params = ctx.sql(query).query()
-> 3190 return self.execute_sql(sql, params, commit=commit)

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:3174, in Database.execute_sql(self, sql, params, commit)
   3171     else:
   3172         commit = not sql[:6].lower().startswith('select')
-> 3174 with __exception_wrapper__:
   3175     cursor = self.cursor(commit)
   3176     try:

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:2950, in ExceptionWrapper.__exit__(self, exc_type, exc_value, traceback)
   2948 new_type = self.exceptions[exc_type.__name__]
   2949 exc_args = exc_value.args
-> 2950 reraise(new_type, new_type(exc_value, *exc_args), traceback)

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:191, in reraise(tp, value, tb)
    189 def reraise(tp, value, tb=None):
    190     if value.__traceback__ is not tb:
--> 191         raise value.with_traceback(tb)
    192     raise value

File ~\Miniconda3\envs\bw2\lib\site-packages\peewee.py:3177, in Database.execute_sql(self, sql, params, commit)
   3175 cursor = self.cursor(commit)
   3176 try:
-> 3177     cursor.execute(sql, params or ())
   3178 except Exception:
   3179     if self.autorollback and not self.in_transaction():

IntegrityError: NOT NULL constraint failed: projectdataset.full_hash

I hope you can help me. Thanks in advance!

cmutel commented 2 years ago

Hi Mario-

If you are using the AB, then you are using Brightway version 2; version 2.5 introduces new capabilities but is currently not backwards compatible.

Please create a new environment and follow the AB installation instructions exactly. If you still have problems, write a reply to this comment and we will fix it :)

-Chris