Hi, I've been struggling for the past few days to figure out why my code is unable to run in PyCharm. I would really appreciate any guidance to resolve this.
I've changed my System Interpreter in PyCharm to SageMath's, defining the path
/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/bin/python3
Below is a sample test code I use:
from sage.all import * B = matrix(GF(3), [ [2, 2, 1, 2, 1, 1, 0, 1, 0, 1], [2, 0, 1, 1, 2, 1, 2, 2, 0, 0], [0, 0, 1, 1, 0, 1, 0, 2, 2, 1], [2, 2, 0, 2, 0, 2, 1, 0, 1, 1], [1, 0, 2, 2, 2, 1, 1, 2, 1, 2], [2, 2, 2, 0, 2, 0, 2, 1, 1, 2], [0, 2, 1, 0, 1, 2, 2, 2, 2, 0], [0, 0, 1, 2, 2, 1, 0, 0, 0, 1], [2, 2, 1, 0, 0, 1, 0, 2, 0, 0], [0, 2, 1, 0, 1, 1, 2, 2, 0, 0] ]) print('Rank') print(B.rank())
C = codes.LinearCode(B)
below is problematic
C.minimum_distance()
In PyCharm, I am able to find the rank, and also construct the LinearCode object. But I can't seem to use the minimum_distance function.
I run into an error suggesting I can't access the GAP functionalities
TypeError: unable to start gap because the command 'gap -A -l "/private/var/tmp/sage-10.3-current/local/lib/gap;/private/var/tmp/sage-10.3-current/local/share/gap" -b -p -T -E -m 64m /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/ext_data/gap/sage.g' failed: The command was not found or was not executable: gap.
For completeness, the full error message is below:
Traceback (most recent call last): File "/Users/jianxiansim/PycharmProjects/qLDPC Codes/TEST.py", line 20, in <module> C.minimum_distance() File "sage/misc/cachefunc.pyx", line 1967, in sage.misc.cachefunc.CachedMethodCaller.__call__ (build/cythonized/sage/misc/cachefunc.c:13535) File "sage/misc/cachefunc.pyx", line 1842, in sage.misc.cachefunc.CachedMethodCaller._instance_call (build/cythonized/sage/misc/cachefunc.c:12984) File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/coding/linear_code.py", line 1420, in minimum_distance return self._minimum_weight_codeword(algorithm).hamming_weight() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/coding/linear_code.py", line 1465, in _minimum_weight_codeword current_randstate().set_seed_gap() File "sage/misc/randstate.pyx", line 721, in sage.misc.randstate.randstate.set_seed_gap (build/cythonized/sage/misc/randstate.c:5339) File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/interface.py", line 671, in __call__ return self._parent.function_call(self._name, list(args), kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/gap.py", line 867, in function_call args, kwds = self._convert_args_kwds(args, kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/interface.py", line 573, in _convert_args_kwds args[i] = self(arg) ^^^^^^^^^ File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/interface.py", line 306, in __call__ result = self._coerce_from_special_method(x) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/interface.py", line 334, in _coerce_from_special_method return (x.__getattribute__(s))(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/structure/sage_object.pyx", line 749, in sage.structure.sage_object.SageObject._gap_ (build/cythonized/sage/structure/sage_object.c:8741) File "sage/structure/sage_object.pyx", line 725, in sage.structure.sage_object.SageObject._interface_ (build/cythonized/sage/structure/sage_object.c:8164) File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/interface.py", line 299, in __call__ return cls(self, x, name=name) ^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/interfaces/expect.py", line 1525, in __init__ raise TypeError(*x.args) TypeError: unable to start gap because the command 'gap -A -l "/private/var/tmp/sage-10.3-current/local/lib/gap;/private/var/tmp/sage-10.3-current/local/share/gap" -b -p -T -E -m 64m /private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/ext_data/gap/sage.g' failed: The command was not found or was not executable: gap.
I encounter no such issue in JupyterLab when I open it directly from the SageMath Launcher, and run the same code. How should I configure my PyCharm for this? Thank you!