google-deepmind / mathematics_dataset

This dataset code generates mathematical question and answer pairs, from a range of question types at roughly school-level difficulty.
Apache License 2.0
1.8k stars 249 forks source link

cannot import name 'base_solution_linear' #14

Closed oucler closed 4 years ago

oucler commented 4 years ago

After cloning the repository I tried to run "python generate_to_file.py" but it generates an error:

Traceback (most recent call last): File "generate_file.py", line 39, in from mathematics_dataset import generate File "/home/ucleraiserver/.conda/envs/torch/lib/python3.7/site-packages/mathematics_dataset/generate.py", line 29, in from mathematics_dataset.modules import modules File "/home/ucleraiserver/.conda/envs/torch/lib/python3.7/site-packages/mathematics_dataset/modules/modules.py", line 21, in from mathematics_dataset.modules import algebra File "/home/ucleraiserver/.conda/envs/torch/lib/python3.7/site-packages/mathematics_dataset/modules/algebra.py", line 25, in from mathematics_dataset import example File "/home/ucleraiserver/.conda/envs/torch/lib/python3.7/site-packages/mathematics_dataset/example.py", line 23, in from mathematics_dataset.util import composition File "/home/ucleraiserver/.conda/envs/torch/lib/python3.7/site-packages/mathematics_dataset/util/composition.py", line 28, in from mathematics_dataset.sample import polynomials File "/home/ucleraiserver/.conda/envs/torch/lib/python3.7/site-packages/mathematics_dataset/sample/polynomials.py", line 33, in from sympy.solvers.diophantine import base_solution_linear as diophantine_solve_linear_2d ImportError: cannot import name 'base_solution_linear' from 'sympy.solvers.diophantine' (/home/ucleraiserver/.conda/envs/torch/lib/python3.7/site-packages/sympy/solvers/diophantine/init.py)

Do you know how to resolve it?

davidsaxton commented 4 years ago

Which version of sympy are you using?

minimario commented 4 years ago

I had the same error, and I resolved it by going to mathematics_dataset/sample/polynomials.py and replacing from sympy.solvers.diophantine import base_solution_linear as diophantine_solve_linear_2d with from sympy.solvers.diophantine.diophantine import base_solution_linear as diophantine_solve_linear_2d on line 33.

oucler commented 4 years ago

sympy

I am using sympy: 1.6 .

oucler commented 4 years ago

from sympy.solvers.diophantine.diophantine import base_solution_linear as diophantine_solve_linear_2d

Thanks a lot, @minimario. It did the trick.