当我尝试在终端中运行任何 anaconda 命令(conda、upyter notebook、pip3...)时,它会抛出以下错误:
>conda
Traceback (most recent call last):
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/cli/main.py", line 36, in main_subshell
from ..base.context import context
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/base/context.py", line 35, in <module>
from ..common.configuration import (
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/common/configuration.py", line 27, in <module>
from pathlib import Path
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/pathlib.py", line 10, in <module>
from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (/Users/thejavanoob/anaconda3/lib/python3.11/collections/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/thejavanoob/anaconda3/bin/conda", line 13, in <module>
sys.exit(main())
^^^^^^
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/cli/main.py", line 109, in main
return conda_exception_handler(main, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 389, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 20, in __call__
return self.handle_exception(exc_val, exc_tb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 52, in handle_exception
from .exceptions import (
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/conda/exceptions.py", line 15, in <module>
import requests
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/requests/__init__.py", line 147, in <module>
from . import packages, utils
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/requests/utils.py", line 19, in <module>
import zipfile
File "/Users/thejavanoob/anaconda3/lib/python3.11/zipfile.py", line 19, in <module>
import pathlib
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/pathlib.py", line 10, in <module>
from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (/Users/thejavanoob/anaconda3/lib/python3.11/collections/__init__.py)
>jupyter notebook
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/bin/jupyter", line 5, in <module>
from jupyter_core.command import main
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/jupyter_core/command.py", line 21, in <module>
from . import paths
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/jupyter_core/paths.py", line 19, in <module>
from pathlib import Path
File "/Users/thejavanoob/anaconda3/lib/python3.11/site-packages/pathlib.py", line 10, in <module>
from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/collections/__init__.py)
我尝试重新安装 anaconda,问题仍然存在。只运行 python 就可以了,在 anaconda navigator 中运行 Jupyter Notebook 也可以正常工作。
collections.Sequence
在 Python 3.7 中已弃用,但您正在使用 Python 3.11 site-packages 目录运行带有 Python 3.12 解释器的系统范围内安装的 Jupyter。这真是一团糟...:)
我建议从头开始:
/Users/thejavanoob/anaconda3/
不是一个东西(您可以重命名它,而不是删除它)——如果成功,您根本不应该在命令行上有 conda
可用PATH
jupyter
(请参阅 pip list
);如果这有效,那么您根本不应该在命令行中使用 jupyter
一般来说,除非你知道你需要 Anaconda,否则我可能会避免它带来的额外复杂性。