My python3 kernel for jupyter notebook was not starting, so I uninstalled it. I then ran these commands to create a new python3 kernel.
python3 -m pip install ipykernel
python3 -m ipykernel install --user
However, I get an error when running python3 -m ipykernel install --user.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/ipykernel/connect.py", line 11, in <module>
from IPython.core.profiledir import ProfileDir
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/__init__.py", line 56, in <module>
from .terminal.embed import embed
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/IPython/terminal/interactiveshell.py", line 19, in <module>
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
from .application import Application
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/application/__init__.py", line 1, in <module>
from .application import Application
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/application/application.py", line 42, in <module>
from prompt_toolkit.buffer import Buffer
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/buffer.py", line 33, in <module>
from .auto_suggest import AutoSuggest, Suggestion
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/auto_suggest.py", line 19, in <module>
from .document import Document
File "/Users/user1/Library/Python/3.6/lib/python/site-packages/prompt_toolkit/document.py", line 8, in <module>
from typing import (
ImportError: cannot import name 'NoReturn'
This is the same error I was getting with the original python3 kernel before I removed it. How can I solve this issue?
I solved this issue by uninstalling and reinstalling Anaconda.
It seems, like it's problem with python version, Typing.NoReturn is new for python 3.6.2.
Try to install prompt-toolkit with a lower version, for instance 2.0.10. It worked for me:
python3 -m pip install prompt-toolkit==2.0.10
Then try again:
python3 -m ipykernel install --user
Related
Whenever I run a command related to pip, or pip itself, it just returns an exception and it doesn't install anything
Here's the exception info:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/configuration.py", line 27, in <module>
from pip._internal.utils.misc import ensure_dir, enum
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 38, in <module>
from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_vendor/tenacity/__init__.py", line 522, in <module>
from pip._vendor.tenacity._asyncio import AsyncRetrying
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pip/_vendor/tenacity/_asyncio.py", line 19, in <module>
from asyncio import sleep
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
from .base_events import *
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/base_events.py", line 296
future = tasks.async(future, loop=self)
I was running pip commands to install libraries on replit (because upm doesn't work well), but after uninstalling discord.py, it doesn't seem to work properly anymore
from my experience it is much better to use the pip module instead of the executable.
python3 -m pip install --upgrade pip # upgrade pip
python3 -m pip install replit # install the desired module
I am trying to use Jupyter Notebooks on a Mac M1 within a local pipenv environment. Here is the commands I use:
(in directory)>pipenv shell
(in directory)>pipenv install pandas
(in directory)>pipenv install ipykernel
(in directory)>python -m ipykernel
Note that this does NOT happen during global python environment, where I don't use pipenv and python -m ipykernel works as intended along with Jupyter notebook.
This is the response I get from the last command given.
❯ python -m ipykernel
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/__main__.py", line 2, in <module>
from ipykernel import kernelapp as app
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 51, in <module>
from .ipkernel import IPythonKernel
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/ipkernel.py", line 17, in <module>
from .comm import CommManager
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/comm/__init__.py", line 1, in <module>
from .comm import * # noqa
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/comm/comm.py", line 12, in <module>
from ipykernel.kernelbase import Kernel
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/ipykernel/kernelbase.py", line 35, in <module>
import psutil
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/__init__.py", line 123, in <module>
from . import _psosx as _psplatform
File "/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/_psosx.py", line 14, in <module>
from . import _psutil_osx as cext
ImportError: dlopen(/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/_psutil_osx.cpython-310-darwin.so, 0x0002): tried: '/Users/samson11/.local/share/virtualenvs/samson11-XeoODf2Y/lib/python3.10/site-packages/psutil/_psutil_osx.cpython-310-darwin.so'
(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
I encounter an error when creating virtual environment on Ubuntu-16.04.
In particular, virtualenv -p python myenv returns
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 7, in <module>
from virtualenv.__main__ import run_with_catch
File "/usr/local/lib/python3.5/dist-packages/virtualenv/__init__.py", line 3, in <module>
from .run import cli_run, session_via_cli
File "/usr/local/lib/python3.5/dist-packages/virtualenv/run/__init__.py", line 7, in <module>
from ..app_data import make_app_data
File "/usr/local/lib/python3.5/dist-packages/virtualenv/app_data/__init__.py", line 9, in <module>
from platformdirs import user_data_dir
File "/usr/local/lib/python3.5/dist-packages/platformdirs/__init__.py", line 29
result: type[PlatformDirsABC] = getattr(importlib.import_module(module), name)
^
SyntaxError: invalid syntax
meaning incorrect syntax in Python 3.5. However, I have set my default python version on Ubuntu to be Python 3.8.9 i.e., python -V returns Python 3.8.9.
So why does virtualenv refer to Python 3.5 even though Python 3.8.9 is default?
Additional info:
My virtualenv version is 15.0.1
The first line in the traceback refers to /usr/local/bin/virtualenv, which looks like this
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from virtualenv.__main__ import run_with_catch
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_with_catch())
Update:
Running python3 -m pip install virtualenv
returns
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.8/runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in <module>
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
You can use the below command for ensuring that virtualenv refers to python3.8 by default
python3.8 -m virtualenv myenv
Installed plasticityai/magnitude (https://github.com/plasticityai/magnitude#installation)
Getting the following error when trying to run:
ModuleNotFoundError: No module named 'spacy.lang.en.tag_map'
I have reinstalled spacy with newest version using pip3. Running python3.
Command I am trying to run:
python3 -m pymagnitude.converter -i /Users/rob/Desktop/videos/glove.6B/glove.6B.300d.txt -o /Users/rob/Desktop/vectors/
Full output:
Traceback (most recent call last):
File "/usr/local/Cellar/python#3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/local/Cellar/python#3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/usr/local/lib/python3.9/site-packages/pymagnitude/__init__.py", line 80, in <module>
from pymagnitude.third_party.allennlp.commands.elmo import ElmoEmbedder
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/commands/__init__.py", line 8, in <module>
from allennlp.commands.configure import Configure
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/commands/__init__.py", line 13, in <module>
from allennlp.commands.predict import Predict
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/commands/predict.py", line 54, in <module>
from allennlp.predictors.predictor import Predictor, JsonDict
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/predictors/__init__.py", line 13, in <module>
from allennlp.predictors.constituency_parser import ConstituencyParserPredictor
File "/usr/local/lib/python3.9/site-packages/pymagnitude/third_party/allennlp/predictors/constituency_parser.py", line 7, in <module>
from spacy.lang.en.tag_map import TAG_MAP
ModuleNotFoundError: No module named 'spacy.lang.en.tag_map'' ```
Issue is version of Spacy installed via pip was incorrect. Uninstalled Spacy from global pip, and works fine.
When I try to launch Jupyter notebook through Anaconda, I get the following error message:
Traceback (most recent call last):
File "C:\Users\Michael\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\notebook\notebookapp.py", line 49, in
from zmq.eventloop import ioloop
File "C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\zmq\__init__.py", line 47, in
from zmq import backend
File "C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\zmq\backend\__init__.py", line 40, in
reraise(*exc_info)
File "C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\zmq\backend\__init__.py", line 27, in
_ns = select_backend(first)
File "C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\zmq\backend\cython\__init__.py", line 6, in
from . import (constants, error, message, context,
ImportError: cannot import name 'constants' from 'zmq.backend.cython' (C:\Users\Michael\AppData\Roaming\Python\Python37\site-packages\zmq\backend\cython\__init__.py)
How do I go about fixing this? I already tried reinstalling Python and Jupyter (for what it's worth).
Try:
conda uninstall pyzmq
conda install pyzmq
or
pip uninstall pyzmq
pip install pyzmq
source: https://github.com/jupyter/notebook/issues/3435