Juypter will not launch from Anaconda - python

When launching Juypter from Anaconda I receive the following error message:
Traceback (most recent call last):
File "C:\Users\ceo20\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "C:\Users\ceo20\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 80, in
from .services.kernels.kernelmanager import MappingKernelManager
File "C:\Users\ceo20\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 19, in
from jupyter_client.session import Session
File "C:\Users\ceo20\Anaconda3\lib\site-packages\jupyter_client__init__.py", line 4, in
from .connect import *
File "C:\Users\ceo20\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 35, in
from jupyter_core.paths import jupyter_data_dir, jupyter_runtime_dir, secure_write
ImportError: cannot import name 'secure_write' from 'jupyter_core.paths' (C:\Users\ceo20\Anaconda3\lib\site-packages\jupyter_core\paths.py)
Any thoughts?

Try this in Anaconda prompt
pip install --upgrade jupyter_client

pip install --upgrade jupyter_client
This package provides the Python API for starting, managing and communicating with Jupyter kernels. The above code will upgrade jupyter client.

Related

jupyter notebook showing this message, ImportError: cannot import name 'encodestring' from 'base64'

I am new to python and jupyter notebook and I am using windows. Recently I installed Anaconda Navigator 2.3.1 and the python verson 3.9.13 on my computer. After entering the command jupyter notebook on the command-line, my browser doesn't open jupyter notebook, instead that showing me this error message:
(base) C:\Users\USER>jupyter notebook
Traceback (most recent call last):
File "D:\Anaconda3\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "D:\Anaconda3\anaconda3\lib\site-packages\notebook\notebookapp.py", line 79, in <module>
from .services.contents.manager import ContentsManager
File "D:\Anaconda3\anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "C:\Users\USER\AppData\Roaming\Python\Python39\site-packages\nbformat\__init__.py", line 14, in <module>
from . import v1
File "C:\Users\USER\AppData\Roaming\Python\Python39\site-packages\nbformat\v1\__init__.py", line 19, in <module>
from .nbjson import reads as reads_json, writes as writes_json
File "C:\Users\USER\AppData\Roaming\Python\Python39\site-packages\nbformat\v1\nbjson.py", line 19, in <module>
from base64 import encodestring
ImportError: cannot import name 'encodestring' from 'base64' (D:\Anaconda3\anaconda3\lib\base64.py)
I don't understand what should do now? And how to solve this issue! Please help..........
base64.encodestring was deprecated since python 3.1 and finally removed in 3.9
You can compare the official documentation for the base64 library for version 3.8 and 3.9
https://docs.python.org/3.8/library/base64.html
https://docs.python.org/3.9/library/base64.html
I'm not sure exactly how you installed anaconda navigator but i would suggest using the latest distribution of anaconda which includes navigator
This error is caused by nbformat. Check your nbformat with the command 'pip freeze', and look for the nbformat version. Most likely your version is anterior to 5.1.3.
Upgrade to that version with the following command:
pip3 install nbformat==5.1.3
or just 'pip install nbformat==5.1.3' ; depending on your configuration.
It should fix the issue.
Francis Massolin
Services that grow your business!

How do I fix this error in Anaconda Navigator?

When I click on Jupyter Notebook in Anaconda Navigator, I am receiving this error. I was just using Jupyter Notebook and had no issues. I restarted my computer and now I am receiving this.
Traceback (most recent call last):
File "C:\Users\csu5141\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "C:\Users\csu5141\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 44, in
from jinja2 import Environment, FileSystemLoader
File "C:\Users\csu5141\Anaconda3\lib\site-packages\jinja2\__init__.py", line 12, in
from .environment import Environment
File "C:\Users\csu5141\Anaconda3\lib\site-packages\jinja2\environment.py", line 25, in
from .defaults import BLOCK_END_STRING
File "C:\Users\csu5141\Anaconda3\lib\site-packages\jinja2\defaults.py", line 3, in
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
File "C:\Users\csu5141\Anaconda3\lib\site-packages\jinja2\filters.py", line 13, in
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (C:\Users\csu5141\Anaconda3\lib\site-packages\markupsafe\__init__.py)
```
inside environment terminal use pip install markupsafe==2.0.1

Spyder doesn't load after the update 4.2.1

I updated the anaconda Navigator and the Spyder.
But now when I try to launch it, there is the following message:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 210, in main
from spyder.app import mainwindow
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 119, in
from spyder.utils.environ import WinUserEnvDialog
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\environ.py", line 19, in
from spyder.plugins.variableexplorer.widgets.collectionseditor import (
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 57, in
from spyder.plugins.variableexplorer.widgets.collectionsdelegate import (
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 31, in
from spyder.plugins.variableexplorer.widgets.objectexplorer.attribute_model \
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\objectexplorer\__init__.py", line 23, in
from .objectexplorer import ObjectExplorer
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\objectexplorer\objectexplorer.py", line 33, in
from spyder.plugins.editor.widgets.codeeditor import CodeEditor
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\widgets\codeeditor.py", line 70, in
from spyder.plugins.editor.panels import (ClassFunctionDropdown,
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\panels\__init__.py", line 13, in
from .codefolding import FoldingPanel
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\panels\codefolding.py", line 32, in
from spyder.plugins.editor.panels.utils import (
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\editor\panels\utils.py", line 15, in
import textdistance
ModuleNotFoundError: No module named 'textdistance'
Can someone please suggest me what should I do
EDIT
I followed what "CanciuCostin" suggested in the comment.
And now I'm getting the following:
I tried conda install -c anaconda qtconsole and conda update qtconsole as well. But still the message is there.. :/
I had the same error today - with the last line about textdistance. I used conda to install text distance from the same environment as spyder and now I can open Spyder again.
conda install textdistance
My anaconda environment uses Python 3.
Well.. I used conda uninstall qtconsole and then once the uninstallation is complete, I installed it again by the command conda install qtconsole. But then I had to install spyder as well ( conda install sypder ).
Then it worked. But I had to install some libraries like scipy ( conda install scipy )

Cannot install Python 2 kernel in Jupyter Notebook

I am trying to use a Python program written for Python 2.7. I am using a Macbook Pro running Catalina. The program is here: https://github.com/geoss/censumander. The program has two Jupyter Notebooks to practice with. I have Anaconda 4.9.2 installed and pip 20.2.4. When I open Jupyter Notebook it defaults to Python 3 and has no kernel option to change to Python 2. I have used the guide here to try to install the Python 2 kernel: https://ipython.readthedocs.io/en/latest/install/kernel_install.html.
When I run
python2 -m pip install ipykernel
I get back
Could not find a version that satisfies the requirement ipykernel (from versions: )
No matching distribution found for ipykernel.
I am pretty new to using Python (typically use R) and am trying to get the hang of stuff like this, so apologies if the answer here is obvious. I've tried the solutions here to no avail: Jupyter notebook with Python 2 and Python3 Kernel
I have also tried the solutions here: Jupyter Notebook - install python 2. The first solution
$ python2 /path/to/jupyter-notebook
is unclear to me as I don't understand to what file path the code points (for jupyter_notebook). (This is likely a consequence of my noobiness.)
The second,
conda create -n ipykernel_py2 python=2 ipykernel
conda activate ipykernel_py2
python -m ipykernel install --user
triggers the following traceback after the third line:
Traceback (most recent call last):
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/runpy.py", line 163, in _run_module_as_main
mod_name, _Error)
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/runpy.py", line 111, in _get_module_details
__import__(mod_name) # Do not catch exceptions initializing package
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/IPython/__init__.py", line 49, in <module>
from .terminal.embed import embed
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/IPython/terminal/embed.py", line 18, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 16, in <module>
from prompt_toolkit.document import Document
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
from .interface import CommandLineInterface
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/interface.py", line 19, in <module>
from .application import Application, AbortAction
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/application.py", line 3, in <module>
from .buffer import Buffer, AcceptAction
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/buffer.py", line 7, in <module>
from .auto_suggest import AutoSuggest
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/auto_suggest.py", line 13, in <module>
from .filters import to_cli_filter
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/filters/__init__.py", line 33, in <module>
from .base import *
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/filters/base.py", line 5, in <module>
from prompt_toolkit.utils import test_callable_args
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/prompt_toolkit/utils.py", line 9, in <module>
from wcwidth import wcwidth
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/wcwidth/__init__.py", line 12, in <module>
from .wcwidth import ZERO_WIDTH # noqa
File "/opt/anaconda3/envs/ipykernel_py2/lib/python2.7/site-packages/wcwidth/wcwidth.py", line 79, in <module>
from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache
Thanks, all.
From version 5.0 ipykernel only runs on Python 3.4+ (from version 5.2 — 3.5+). To install ipykernel` for Python 2.7 you need an older version:
python2 -m pip install 'ipykernel<5.0'
For backports.functools-lru-cache install or force-reinstall it:
pip install -U backports.functools-lru-cache
or
pip install --ignore-installed backports.functools-lru-cache

Jupyter suddenly won't start without (already-installed) packages

I was having issues installing a package. I cancelled the install mid-solving environment.
Now, when I try to open Jupyter notebook, I receive the following error:
Traceback (most recent call last):
File "/Users/Me/opt/anaconda3/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 80, in <module>
from .services.contents.manager import ContentsManager
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/notebook/services/contents/manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/nbformat/__init__.py", line 32, in <module>
from .validator import validate, ValidationError
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/nbformat/validator.py", line 23, in <module>
raise ImportError(str(e) + verbose_msg)
ImportError: No module named 'importlib_metadata'
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
I tried installing jsonschema and importlib_metadata via conda install. When I do that, I receive this (for both):
# All requested packages already installed.
I tried turning it off and on again; I tried removing and reinstalling Jupyter. Neither worked. This is abhorrently frustrating. What the heck is going on, and why is Jupyter suddenly deciding to not work when it worked perfectly before the weekend? And more importantly, how do I fix this?

Categories

Resources