Closed yr542 closed 5 months ago
"cannot import name 'Sequence' from 'collections'
This is a compatibility bug (with Python 3.8 or something) that has been fixed last year. Could you update your version of sos related pacakges?
I am running sos 0.23.4 for Python 3.10.10 and my version of python is 3.10.8.
What about your version of sos-notebook?
When I run
sos --version
it tells me:
sos 0.23.4 for Python 3.10.10
I meant sos-notebook
, run something like
pip list | grep sos
The code you mentioned:
pip list | grep sos
generates the following output:
jupyterlab-sos 0.9.0
sos 0.23.4
sos-bash 0.20.0
sos-notebook 0.23.4
sos-pbs 0.20.8
sos-python 0.18.4
sos-r 0.19.6
Ok, this looks like a problem with sos-r
. I have pushed a fix and released sos-r
0.19.7. Could you test it?
I tried to update sos-r using the following command:
pip install sos-r -U
then I opened up SoS and tried to run one R command:
sessionInfo()
and I kept getting the following error:
asyncio.run() cannot be called from a running event loop
I ran the following command to know the versions:
pip list | grep sos
and got the following:
jupyterlab-sos 0.9.0
sos 0.23.4
sos-bash 0.20.0
sos-notebook 0.23.4
sos-pbs 0.20.8
sos-python 0.18.4
sos-r 0.19.7
Let me update the docker release of sos-notebook so that we can try to reproduce the problem or compare the versions there.
ok, I updated to the latest versions of the jupyter tool stack with python 3.10 and can reproduce your problem. I cannot yet figure out what has caused it though.
It seems that in Python 3.10 Sequence
has been moved to collections.abc
, and importing from collections.abc
instead should work?
That has been fixed, but the async issue arises again. Looks like some upstream package enhanced async support.
Downgrading jupyter-client
from 8.0.x
(e.g. 8.0.3, 8.0.0, 8.0.0a0) to 7.x.x
(e.g. 7.4.9
) fixes the problem.
8.0.0a0: 30cbf9719551d095dd099682d7cb8ebce2a9a8af
I think what is happening is https://github.com/ipython/ipykernel/commit/aefef5d732a412146ee335d1b14a7d8ab58a6d72
Namely the upstream has used native async
all the time and sos-notebook
has been using a hybrid approach. So the new code
reply_content = self.do_execute(
code, silent, store_history,
user_expressions, allow_stdin,
)
if inspect.isawaitable(reply_content):
reply_content = await reply_content
accept pure do_execute
, or async do_execute
, but not our do_execute
that calls asyncio.run
.
When I try
pip install notebook==7.4.9
it says
ERROR: Could not find a version that satisfies the requirement notebook==7.4.9 (from versions: 4.0.0, 4.0.1, 4.0.2, 4.0.4, 4.0.5, 4.0.6, 4.1.0, 4.2.0b1, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.3.0, 4.3.1, 4.3.2, 4.4.0, 4.4.1, 5.0.0b1, 5.0.0b2, 5.0.0rc1, 5.0.0rc2, 5.0.0, 5.1.0rc1, 5.1.0rc2, 5.1.0rc3, 5.1.0, 5.2.0rc1, 5.2.0, 5.2.1rc1, 5.2.1, 5.2.2, 5.3.0rc1, 5.3.0, 5.3.1, 5.4.0, 5.4.1, 5.5.0rc1, 5.5.0, 5.6.0rc1, 5.6.0, 5.7.0, 5.7.1, 5.7.2, 5.7.3, 5.7.4, 5.7.5, 5.7.6, 5.7.8, 5.7.9, 5.7.10, 5.7.11, 5.7.12, 5.7.13, 5.7.14a0, 5.7.14, 5.7.15, 5.7.16, 6.0.0rc1, 6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.1.0rc1, 6.1.0, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5, 6.1.6, 6.2.0, 6.3.0, 6.4.0a0, 6.4.0a1, 6.4.0rc0, 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.5, 6.4.6, 6.4.7, 6.4.8, 6.4.9, 6.4.10, 6.4.11, 6.4.12, 6.5.0a0, 6.5.0b0, 6.5.0rc0, 6.5.0, 6.5.1, 6.5.2, 7.0.0a1, 7.0.0a2, 7.0.0a3, 7.0.0a4, 7.0.0a5, 7.0.0a6, 7.0.0a7, 7.0.0a8, 7.0.0a9, 7.0.0a10, 7.0.0a11, 7.0.0a12, 7.0.0a13) ERROR: No matching distribution found for notebook==7.4.9
I believe the notebook must be under version 8.x.x in this case?
Just in case I did
pip install notebook==7.0.0a13
and then started a new Jupyter notebooks session. I tried using R markdown and types in sessionInfo()
and it worked. However, when I tried to use SoS while it did connect, when I try to write down code sessionInfo()
it says:
[0]:
NameError Traceback (most recent call last) script_704958943456885391 in
----> sessionInfo() NameError: name 'sessionInfo' is not defined
It still seems to not work.
You need to downgrade jupyter-client
, not notebook
.
However, I am working on a new version of sos-notebook
corresponding to jupyter-client >= 8.0.0
. It is roughly working but more testing is needed. I plan to release it later today.
I did the following
I updated the notebooks. Then I did:
pip install jupyter-client==7.4.9
however, it does not change that I get the following error in SoS and not in R Markdown:
[0]:
NameError Traceback (most recent call last) script_5915805525780421572 in
----> sessionInfo() NameError: name 'sessionInfo' is not defined
I have released sos-notebook 0.24.0, sos-r 0.20.0, sos-python 0.20.0 etc. Basically all language modules need to be upgraded with the update of sos-notebook, which now depends on jupyter-client >= 8.0.0.
Please let me know if you notice any problem with this release.
I did a clean install of SoS. I then did the following command to see:
pip list | grep sos
I got the following:
jupyterlab-sos 0.9.0
sos 0.24.0
sos-bash 0.21.0
sos-notebook 0.24.0
sos-pbs 0.20.8
sos-python 0.20.0
sos-r 0.20.0
I checked R markdown and SoS and both worked for the sessionInfo
command. Thank you.
@BoPeng we are still having an issue when we install sos-notebook from conda-forge. Turns out we may need to update the recipe:
Here it still says juptyer_client > 7. We need to make it >8.0.0. Also perhaps sos>0.19.0?
(there maybe a few other sos-notebook problems that we will try to better understand, organize and post, so later we can fix and release a new version -- please expect our other follow ups!)
It can be a good time to fix this with the new release (for #349),
It seems that I am having an issue running R 4.2.2 on the SoS notebook but it works fine in an R markdown file. I am working on an HPC (runs Linux) and using a Mac Air.
I wrote the following command:
sessionInfo()
Then I got the subsequent error:
"cannot import name 'Sequence' from 'collections' (/home/yr2446/miniconda3/lib/python3.10/collections/__init__.py)"
I tried the following solution R Issues StackOverflow where I ran the following:
pip install -U mkdoc
however this issue persists. Is there anything I can do to resolve this issue so that I can use R in a SoS notebook?