Could not find a kernel matching Python 3. Please select a kernel - python

After I tried to install and register a new virtual environment so I can use it in Jupyter notebook, I ended up with the following problem: any notebook I open or create it displays the error message: "Could not find a kernel matching Python 3. Please select a kernel:"
but there are no kernels registered anymore ...
I couldn't find a good answer although I noticed that many others faced the same problem in the past. Anyone could help?
I am using Ubuntu and pip.
It seems to be a configuration problem with Jupyter.
$ jupyter --paths --debug
JUPYTER_PREFER_ENV_PATH is not set, making the user-level path preferred over the environment-level path for data and config
JUPYTER_NO_CONFIG is not set, so we use the full path list for config
JUPYTER_CONFIG_PATH is not set, so we do not prepend anything to the config paths
JUPYTER_CONFIG_DIR is not set, so we use the default user-level config directory
JUPYTER_PATH is not set, so we do not prepend anything to the data paths
JUPYTER_DATA_DIR is not set, so we use the default user-level data directory
JUPYTER_RUNTIME_DIR is not set, so we use the default runtime directory
config:
/home/florian/.jupyter
/home/florian/..../OCR/ocr_env/etc/jupyter
/usr/local/etc/jupyter
/etc/jupyter
data:
/home/florian/.local/share/jupyter
jupyter kernelspec list
Available kernels:
ocr_env /home/florian/.local/share/jupyter/kernels/ocr_env
python3 /home/florian/.local/share/jupyter/kernels/python3
spark_env /home/florian/.local/share/jupyter/kernels/spark_env
tensorflow /home/florian/.local/share/jupyter/kernels/tensorflow
Another error trying to upgrade pip:
python -m pip install --upgrade pip
Traceback (most recent call last):
File "/home/florian/anaconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/florian/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/__main__.py", line 23, in <module>
from pip._internal.cli.main import main as _main # isort:skip # noqa
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
from pip._internal.utils.logging import get_indentation
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/logging.py", line 18, in <module>
from pip._internal.utils.misc import ensure_dir
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 33, in <module>
from pip._internal.locations import (
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
from . import _distutils, _sysconfig
File "/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/home/florian/anaconda3/lib/python3.8/site-packages/pip/_internal/exceptions.py)

Seems I found a solution like this below:
pip3 install --force-reinstall jupyter_client

julia> import Pkg; Pkg.add("IJulia")
julia> using IJulia
julia> IJulia.notebook
💚 ❤️ 💜
Reference:
julia> is running julia.app on macOS
https://github.com/JuliaLang/IJulia.jl/issues/968#issuecomment-739800974

Related

Error message about 'libsqlite3' when activate environment in jupyter Notebook

I try to activate my env to Jupyter notebook by using:
python -m ipykernel install --user --name native --display-name "python-gpu"
But error message:
Traceback (most recent call last):
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/site-packages/ipykernel/__main__.py", line 2, in <module>
from ipykernel import kernelapp as app
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 18, in <module>
from IPython.core.application import (
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/site-packages/IPython/__init__.py", line 53, in <module>
from .terminal.embed import embed
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/site-packages/IPython/terminal/embed.py", line 15, in <module>
from IPython.core.interactiveshell import DummyMod, InteractiveShell
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 73, in <module>
from IPython.core.history import HistoryManager
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/site-packages/IPython/core/history.py", line 11, in <module>
import sqlite3
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/sqlite3/__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
File "/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: dlopen(/Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/lib-dynload/_sqlite3.cpython-310-darwin.so, 0x0002): Symbol not found: _sqlite3_enable_load_extension
Referenced from: /Users/nianhua/opt/anaconda3/envs/native/lib/python3.10/lib-dynload/_sqlite3.cpython-310-darwin.so
Expected in: /usr/lib/libsqlite3.dylib
It seems like something is wrong with my libsqlite3, but it goes well in my terminal.
My laptop is a Macbook pro with M1Pro. And I'm building an arm64 python environment in M1 version Anaconda.
Does anyone know how I can get around this?
I had the same problem and I solved by installing a newer version:
mamba install sqlite=3.40.0
always checking that the new library is coming from conda-forge/osx-arm64.

ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions'

I am quite new to programming so don't be mad if I get something wrong.
I updated pip to its latest version (something like 21.x.x) and I tried to install the Detectron2 Git repo.
But anything related with pip (even when checking its version) I get the following Traceback:
Traceback (most recent call last):
File "/Users/user/opt/anaconda3/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 8, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 22, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/progress_bars.py", line 9, in <module>
from pip._internal.utils.logging import get_indentation
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/logging.py", line 14, in <module>
from pip._internal.utils.misc import ensure_dir
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 29, in <module>
from pip._internal.locations import get_major_minor_version, site_packages, user_site
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
from . import _distutils, _sysconfig
File "/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/Users/user/opt/anaconda3/lib/python3.8/site-packages/pip/_internal/exceptions.py)
Is there a solution for my problem?
I also tried downgrading to an earlier version but as I said any comment with pip inside gives me this Traceback...
If anyone out there can help me I would be so grateful!
I was having the same error after upgrading to pip 20.x.x, there is a solution on GitHub(https://github.com/pypa/pip/issues/5599) which helped me to understand the problem, but it doesn't help me. So let's come to the solution
Solution
Manually remove or delete the pip file and pip-20.2.4-py3.7.egg-info file from the directory, which in your case is located in /Users/user/opt/anaconda3/lib/python3.7/site-packages and for some it's in /home/user/anaconda3/lib/python3.7/site-packages.
Now use conda remove --force pip to completely remove pip from your system.
Finally, use conda install -c anaconda pip to install pip in your anaconda environment.
For me, it worked, hope it will work for you too
best of luck

Python 3 - spaCy installation error: "no module preshed.bloom"

I install spacy on a Jupyter notebook Python 3, with Windows 10, and then try to install the English language model.
import spacy
!python -m spacy download en
The latter command givest me the following error:
Traceback (most recent call last):
File "C:\Users\naimb\Anaconda3\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\naimb\Anaconda3\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\naimb\Anaconda3\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\__init__.py", line 12, in <module>
from .cli.info import info as cli_info
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\cli\__init__.py", line 6, in <module>
from .train import train # noqa: F401
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\cli\train.py", line 17, in <module>
from ..gold import GoldCorpus
File "morphology.pxd", line 13, in init spacy.gold
File "vocab.pxd", line 27, in init spacy.morphology
File "vocab.pyx", line 20, in init spacy.vocab
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\lemmatizer.py", line 8, in <module>
from .lookups import Lookups
File "C:\Users\naimb\Anaconda3\lib\site-packages\spacy\lookups.py", line 6, in <module>
from preshed.bloom import BloomFilter
ModuleNotFoundError: No module named 'preshed.bloom'
What's the preshed.bloom module? Following the answer in this question, I loaded the preshed wheel from this page (preshed‑3.0.2‑cp38‑cp38‑win_amd64.whl), but the problem remains.
Does anyone know how to fix this problem?
This is probably a version mismatch in one of spacy's dependencies. You shouldn't need to download wheels from a third-party site, installing with pip (or conda) should just work.
You can try pip install -U spacy in your current environment to update all the dependencies or if that doesn't help, try installing spacy from scratch in a new virtual environment.
(The answer you linked is a bit out-of-date, but as mentioned in the other answers, spacy only works with 64-bit python, so double-check that, too.)

ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' for windows

I found 0 topics about this issue for Windows, only for Ubuntu, MAc etc.
When I try to install any package via Pycharm, e.g. urllib, matplotlib, heidi, I get the exact same error message as below.
Project interpreter is Anaconda Python 3.7.
Any idea how this can solved?
Error: Traceback (most recent call last):
File "E:\Download\PROGIK\Charm Community Edition 2018.3.5\helpers\packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 201, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\vcs\subversion.py", line 9, in <module>
from pip.index import Link
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\wheel.py", line 35, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\_vendor\distlib\scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\_vendor\distlib\compat.py", line 66, in <module>
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' (E:\Download\PROGIK\Anaconda\lib\urllib\request.py)
Edit: with pip I have only problem with matplotlib, which is another topic:
Cannot install matplotlib. Fatal error LNK1181, Visual Studio fail
Simply went into packages folder and deleted matplotlib package manually because could not make it display graphs in Jupyter (didnt try in Pycharm). Trying to reinstall it now, hopefully it will fix the issue.
To install packages whithin anaconda environment under Windows10, you should use "Anaconda prompt" (find it in win menu)
It starts (Base) venv by default and installs packages in it. Therefore using Python interpreter distributed with Anaconda you will be able to import them with no side actions.
Besides matplotlib is installed there by default

Getting AssertionError message installing pip on windows 10

After having downloaded get-pip.py attempting to install, and opening cmd window in windows 10 I am getting the following error message when I type pip and hit enter:
Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\Users\adamh>pip
Traceback (most recent call last):
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\utils\__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 70, in <module>
from pip._vendor import appdirs
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\appdirs.py", line 510, in <module>
import win32com.shell
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\win32com\__init__.py", line 6, in <module>
import pythoncom
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\win32\lib\pywintypes.py", line 117, in __import_pywin32_system_module__
assert sys.modules[modname] is not old_mod
AssertionError
C:\Users\adamh>
I tried all of the upgrades and such but none of them have been successful. Thank you very much for any help provided. Sincerely, will_learn
First Check if your python is running is properly from command prompt.
Open command prompt and run python it should show your python version else install it properly and add its path in environment variables
Mostly Pip should be already included in Python 2.7.9+ or 3.4+, but if for whatever reason it is not there, you can use the following one-liner.
Download https://bootstrap.pypa.io/get-pip.py and run it with Administrator permission python get-pip.py (If you are on Linux, use sudo python get-pip.py)
You must to add pip's path into Environment Variables. Pip is contained in python's script directory.
Example my case: C:\Python35\Scripts\pip.exe
To add path to environment variables.
Hold Win and press Pause.
Click Advanced System Settings.
Click Environment Variables.
Add C:\Python35\Scripts (Sorry I don't know name of python 3.5's directory) to the Path on System variables.
Restart Command Prompt.
Edit
In another way, you can use pip-Win instead of pip. Read more here: https://sites.google.com/site/pydatalog/python/pip-for-windows

Categories