prime must be a prime in the integers but 2 is not
I put
v = QQ.valuation(2)
and get the error prime must be a prime in the integers but 2 is not
I put
v = QQ.valuation(2)
and get the error prime must be a prime in the integers but 2 is not
The problem is caused by
from sympy import * overwriting the definition of Sage's Integer class:
print(Integer)
from sympy import *
print(Integer)
prints:
<class 'sage.rings.integer.Integer'>
<class 'sympy.core.numbers.Integer'>
Possible solutions:
sympy, not *or re-import Integer from Sage:
from sympy import *
from sage.rings.integer import Integer
or explicitly specify the type of 123 - like:
ZZ(123).valuation(3)
But still I have problems: I have definitions in a file,I make it minimal with: from sympy import divisors from mpmath import log from sage.rings.integer import Integer
def decompose(n): d=divisors(n)[1] d=ZZ(d) a=d.valuation(2) return a
then with from MinimalExample import * decompose(12345) get an error: name 'ZZ' is not defined
if I eliminate d=ZZ(D) the error is: AttributeError: 'int' object has no attribute 'valuation'
Are you running your example from Sage? Otherwise you also need from sage.all import *
Btw, divisors are present in Sage as well, you don't need sympy for that.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2025-12-07 11:27:33 +0100
Seen: 265 times
Last updated: Dec 08 '25
How do I get the classical N1 object rather than N*? (NN)
'list indices must be integers, not tuple' error in newbie script
get multiplicative subgroup of Z/nZ
construction of product rings Z/nZ x Z/mZ
Problem with numpy integers and floats
List members of each subgroup of integers modulo n
numpy.int64 vs. sage.rings.integer.Integer [closed]
Permutations indexed from zero
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
It works fine at sagecell. What is your Sage version and what error do you see?
It is Sage 10.6 the error is after import something:
from sympy import * 123.valuation(3)
AttributeError Traceback (most recent call last) Cell In[2], line 2 1 from sympy import * ----> 2 Integer(123).valuation(Integer(3))
AttributeError: 'Integer' object has no attribute 'valuation'
Yesterday I was trying many things and end with the absurd error " prime must be a prime in the integers but 2 is not" Today I can not reproduce this error, but first it is the one above.