Ask Your Question

Revision history [back]

Try using the "SageMath Py3" kernel in CoCalc, which uses a Python3-based SageMath, rather than a Python2-based one.

Try using the "SageMath Py3" kernel in CoCalc, which Sage uses a preparser, which transforms the "75" in your input into the Sage integer 75; quotients with this "75" as a numerator or denominator thereafter become rationals instead of floats.

The workaround for you is to input "75r" which stands for the raw Python integer 75, not to be preparsed by the Sage preparser.

So this will work (after installing tqdm for the Python of the Sage you are using):

from tqdm import tqdm_notebook as tqdm
for i in tqdm(range(50), total=75r):

Note: if you want to use a Python3-based SageMath, rather than Sage in CoCalc, you can select the kernel "SageMath (development, Py3)" from the list of kernels in CoCalc's Jupyter notebook.

To install extra pip packages for that Sage, do the following in a Python2-based one.

CoCalc terminal:

Select the development version of Sage:

~$ sage_select develop
Making default sage /ext/bin/sage-develop by creating ~/bin/sage symbolic link:
Restart your project server!

Then restart your project server (go to the project settings, and click "Restart Project" halfway down the right column).

Reopen the CoCalc terminal and check you have the right version of Sage:

~$ sage --version
SageMath version 8.8.beta1, Release Date: 2019-04-07

and that it is Python3-based:

~$ sage --python --version
Python 3.7.3

Then you can install extra Python packages for it:

~$ sage --pip install --user tqdm
Collecting tqdm
  Downloading (48kB)
    100% |████████████████████████████████| 51kB 5.6MB/s 
Installing collected packages: tqdm
Successfully installed tqdm-4.31.1

Then in Jupyter worksheets using the "SageMath (development, Py3)" kernel you can import tqdm and use it.