RSchwieger / Classifier-construction-in-Boolean-Networks-using-algebraic-methods

1 stars 1 forks source link

running example fails with TypeError: metaclass is not safe #1

Open hklarner opened 3 years ago

hklarner commented 3 years ago

OS: Ubuntu

installed sage with

sudo apt install sagemath

tried to run an example with

sage -python example1.py

Got error

Traceback (most recent call last):
  File "example1.py", line 2, in <module>
    from sage.all import *
  File "/usr/lib/python2.7/dist-packages/sage/all.py", line 87, in <module>
    from sage.misc.all       import *         # takes a while
  File "/usr/lib/python2.7/dist-packages/sage/misc/all.py", line 84, in <module>
    from .functional import (additive_order,
  File "/usr/lib/python2.7/dist-packages/sage/misc/functional.py", line 27, in <module>
    from sage.rings.complex_double import CDF
  File "sage/rings/complex_double.pyx", line 1, in init sage.rings.complex_double
  File "sage/rings/ring.pyx", line 1, in init sage.rings.ring
  File "sage/structure/parent_gens.pyx", line 1, in init sage.structure.parent_gens
  File "sage/structure/parent_base.pyx", line 1, in init sage.structure.parent_base
  File "sage/structure/parent_old.pyx", line 1, in init sage.structure.parent_old
  File "sage/structure/parent.pyx", line 1, in init sage.structure.parent
  File "sage/structure/category_object.pyx", line 62, in init sage.structure.category_object
  File "/usr/lib/python2.7/dist-packages/sage/categories/category.py", line 107, in <module>
    from sage.misc.unknown import Unknown
  File "/usr/lib/python2.7/dist-packages/sage/misc/unknown.py", line 11, in <module>
    from sage.structure.unique_representation import UniqueRepresentation
  File "/usr/lib/python2.7/dist-packages/sage/structure/unique_representation.py", line 569, in <module>
    class CachedRepresentation(six.with_metaclass(ClasscallMetaclass)):
  File "/home/hannes/.local/lib/python2.7/site-packages/six.py", line 809, in with_metaclass
    return type.__new__(metaclass, 'temporary_class', (), {})
TypeError: type.__new__(metaclass) is not safe, use sage.misc.classcall_metaclass.ClasscallMetaclass.__new__()

Have you seen this error before? Any suggestions how to fix it?

hklarner commented 3 years ago
sage --version
SageMath version 8.1, Release Date: 2017-12-07

Die Readme auf dem Branch fix-sagemath-version sagt

To run the script use: python3 example*.py

aber da bekomme ich einen ModuleNotFoundError:

python3 example1.py
ModuleNotFoundError: No module named 'sage'

Auf dem neuen Branch hast Du nur Tabs gegen Spaces getauscht, oder? Bekomme dieselben Fehler wie zuvor:

git checkout fix-sagemath-version
python3 example1.py
ModuleNotFoundError: No module named 'sage'
sage -python example1.py
TypeError: type.__new__(metaclass) is not safe, use sage.misc.classcall_metaclass.ClasscallMetaclass.__new__()

Ich kann das Docker Image hochfahren. Da läuft Sage 9.0:

docker build -t rschwieger:classifier .
docker run -v ~/IdeaProjects/Classifier-construction-in-Boolean-Networks-using-algebraic-methods:/media -it rschwieger:classifier
root@187ff98181e8:/media# sage --version
SageMath version 9.0, Release Date: 2020-01-01
exit

Das example1.py läuft im Docker Image ohne Fehler durch. Hier die Ergebnisse pro Branch / Befehl.

Auf dem fix-sagemath-version Branch

git checkout fix-sagemath-version
docker run -v ~/IdeaProjects/Classifier-construction-in-Boolean-Networks-using-algebraic-methods:/media -it rschwieger:classifier
cd media
python3 example1.py
...
There are 10 solutions
sage -python example1.py
...
There are 10 solutions
sage -python3 example1.py
...
There are 10 solutions
exit

Auf dem Master Branch:

git checkout master
docker run -v ~/IdeaProjects/Classifier-construction-in-Boolean-Networks-using-algebraic-methods:/media -it rschwieger:classifier
cd media
python3 example1.py
TabError: inconsistent use of tabs and spaces in indentation
python example1.py
bash: python: command not found
sage -python example1.py
TabError: inconsistent use of tabs and spaces in indentation
sage -python3 example1.py
TabError: inconsistent use of tabs and spaces in indentation
hklarner commented 3 years ago

to install sagemath 9.0 on ubuntu 18.04 see

RSchwieger commented 3 years ago

Ich habe jetzt den Fix-Branch in den master gemergt, da im Docker die neuere sage Version installiert ist. Und ja, ich hatte im Dockercontainer Probleme mit den Tabs. Deswegen hatte ich die nochmal geändert.