Error While Creating A Note Book In Jupyter - python

Hello I am Creating A New Jupyter Note Book For The First Time Following This Documentation
I typed
jupyter notebook
and this is the error that i got
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py", line 27, in <module>
import resource
ModuleNotFoundError: No module named 'resource'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\josti\AppData\Local\Programs\Python\Python38-32\Scripts\jupyter-notebook.EXE\__main__.py", line 7, in <module>
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
app.initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1368, in initialize
self.init_webapp()
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1156, in init_webapp
self.web_app = NotebookWebApplication(
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 151, in __init__
settings = self.init_settings(
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 263, in init_settings
nbextensions_path=jupyter_app.nbextensions_path,
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 874, in nbextensions_path
from IPython.paths import get_ipython_dir
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\IPython\__init__.py", line 49, in <module>
from .terminal.embed import embed
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\IPython\terminal\embed.py", line 19, in <module>
from IPython.terminal.ipapp import load_default_config
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\IPython\terminal\ipapp.py", line 30, in <module>
from IPython.core.magics import ScriptMagics
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\IPython\core\magics\__init__.py", line 21, in <module>
from .execution import ExecutionMagics
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\IPython\core\magics\execution.py", line 46, in <module>
from IPython.utils.timing import clock, clock2
File "c:\users\josti\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py", line 64, in <module>
clocku = clocks = clock = time.clock
AttributeError: module 'time' has no attribute 'clock'
I tried to
pip3 install --upgrade pip
Even tho i have the latest version of PIP
install resource
pip install resource
and it did not work

module 'time' has no attribute 'clock'
Are you using Python 3.8? This appears to be an issue with Python 3.8. I would suggest reverting to a older version of Python (3.7 works fine) until the libraries are resolved.
Reference:
AttributeError: module 'time' has no attribute 'clock' in Python 3.8
https://github.com/jupyter/notebook/issues/5272

Related

Pycharm: ModuleNotFoundError: No module named 'distutils.cmd'

I'm trying to use opencv module with python.
I have Python3.10.
I installed the module and with the use of Python interpreter in the command line, writing "import cv2" it works fine.
Now, I want to use opencv inside PyCharm.
I went to "File->Settings->Project->Python Interpreter" and then I tried to add the module "opencv-python" but it returned:
"Error occurred when installing package 'opencv-python'. Details.."
and clicking on Details, this is the command output:
Error: Traceback (most recent call last):
File "/opt/pycharm-community-2022.3.1/plugins/python-ce/helpers/packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "/usr/lib/python3.9/runpy.py", line 210, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/build_env.py", line 20, in <module>
from pip._internal.cli.spinners import open_spinner
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/cli/spinners.py", line 9, in <module>
from pip._internal.utils.logging import get_indentation
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 29, in <module>
from pip._internal.utils.misc import ensure_dir
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 42, in <module>
from pip._internal.locations import get_major_minor_version
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/locations/__init__.py", line 67, in <module>
from . import _distutils
File "/home/user/Progetti/SottoProgettiPython/RiconoscimentoFacciale/venv/lib/python3.9/site-packages/pip/_internal/locations/_distutils.py", line 20, in <module>
from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils.cmd'
I didn't found any working solutions for the module distutils.
I tried to install and reinstall the module "python3.10-distutils" but it is already installed.
Someone knows how to solve the problem?
Thanks in advance,
Marco

Suddenly all virtual envs fail

I use vscode and I'm working with Jupyter in this particular example. Yesterday, I was doing my work fine. Today, my venv is broken, so I deleted and started again:
python -m venv venv
./venv/Scripts/Activate
Okay, so I have brand new venv now. So lets try updating pip:
python -m pip --upgrade pip
And I get this error:
Traceback (most recent call last):
File "C:\Users\jmarshall\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\jmarshall\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\_internal\__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\_vendor\urllib3\__init__.py", line 7, in <module>
from .connectionpool import (
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 11, in <module>
from .exceptions import (
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\_vendor\urllib3\exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Users\jmarshall\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 71, in <module>
import email.parser
ModuleNotFoundError: No module named 'email.parser'
Okay, lets try to ignore this an set up jupyter.
pip install wheel
pip install juypterlab
pip install ipykernel
Then when I try running a cell in that notebook in VSCode I get this error:
Kernel died (code: 1). ModuleNotFoundError: No module named 'email.parser',
Traceback (most recent call last):
File "C:\Users\jmarshall\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\jmarshall\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "c:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\ipykernel\kernelapp.py", line 22, in <module>
from IPython.core.application import (
File "c:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\IPython\__init__.py", line 56, in <module>
from .terminal.embed import embed
File "c:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\IPython\terminal\embed.py", line 17, in <module>
from IPython.terminal.ipapp import load_default_config
File "c:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\IPython\terminal\ipapp.py", line 28, in <module>
from IPython.core.magics import (
File "c:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\IPython\core\magics\__init__.py", line 18, in <module>
from .code import CodeMagics, MacroToEdit
File "c:\Users\jmarshall\source\mdgattribution\venv\lib\site-packages\IPython\core\magics\code.py", line 23, in <module>
from urllib.request import Request, urlopen
File "C:\Users\jmarshall\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 88, in <module>
import http.client
File "C:\Users\jmarshall\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 71, in <module>
import email.parser
ModuleNotFoundError: No module named 'email.parser'
What the heck is going on here?
Edit1
I've just proven it will error on the 3.8 global interpreter instance, even though I have other notebooks working on that. I've added a screenshot of the project.
You created a package named email, you need to rename it to some other names.

ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'

I'm working on a Rally reporting tool for my team in Python, and I'm trying to package it using cx-freeze. I'm getting a ModuleNotFound error, and I'm wondering if it's because pygal isn't supported by cx-freeze (really hoping this isn't the case because I'd have to rewrite a lot of things)
celinaperalta$ /Users/celinaperalta/Documents/NYLTesting/rally-exports/build/exe.macosx-10.9-x86_64-3.7/RallyGUI ; exit;
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Freeze/initscripts/__startup__.py", line 40, in run
module.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Freeze/initscripts/Console.py", line 37, in run
exec(code, {'__name__': '__main__'})
File "RallyGUI.py", line 8, in <module>
File "/Users/celinaperalta/Documents/NYLTesting/rally-exports/build/exe.macosx-10.9-x86_64-3.7/RallyReportTool.py", line 7, in <module>
import pygal
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pygal/__init__.py", line 28, in <module>
import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 959, in <module>
class Environment:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 963, in Environment
self, search_path=None, platform=get_supported_platform(),
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 190, in get_supported_platform
plat = get_build_platform()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 395, in get_build_platform
plat = get_platform()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 675, in get_platform
get_config_vars(),
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 551, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 422, in _init_posix
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'
cx_freeze does not include all the packages automatically. When you find ModuleNotFoundError, you need to inlcude the module explicitly in your setup like -
build_exe_options = {'packages': ['_sysconfigdata_m_darwin_darwin']}

Can't launch Jupyter Notebook ModuleNotFoundError: No module named 'resource'

I've been using Jupyter Notebook from the command line for a month now, today I didn't shut the running notebook and put my laptop to sleep for 4 hours. After turning my laptop back on I tried to run the notebook again and I'm getting the same error ever since. Please help me out.
Traceback (most recent call last):
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py", line 27, in <module>
import resource
ModuleNotFoundError: No module named 'resource'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Chinmay\AppData\Local\Programs\Python\Python38-32\Scripts\jupyter-notebook.EXE\__main__.py", line 9, in <module>
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\jupyter_core\application.py", line 270, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
app.initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1769, in initialize
self.init_webapp()
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1451, in init_webapp
self.web_app = NotebookWebApplication(
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 153, in __init__
settings = self.init_settings(
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 269, in init_settings
nbextensions_path=jupyter_app.nbextensions_path,
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\notebook\notebookapp.py", line 1120, in nbextensions_path
from IPython.paths import get_ipython_dir
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\__init__.py", line 49, in <module>
from .terminal.embed import embed
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\terminal\embed.py", line 19, in <module>
from IPython.terminal.ipapp import load_default_config
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\terminal\ipapp.py", line 30, in <module>
from IPython.core.magics import ScriptMagics
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\core\magics\__init__.py", line 21, in <module>
from .execution import ExecutionMagics
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\core\magics\execution.py", line 46, in <module>
from IPython.utils.timing import clock, clock2
File "c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py", line 64, in <module>
clocku = clocks = clock = time.clock
AttributeError: module 'time' has no attribute 'clock'```
Open this file: c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\utils\timing.py
change import time to import timeit
change time.clock to timeit.default_timer
This worked for me, should work for you.
conda update --all
this working
For me this happened while trying to install some other pip libraries. Looks like one of my pip libraries got downgraded and that caused this error. So upgrading it back resolved the issue.
pip3 install --upgrade jupyter-console
pip3 install --upgrade jupyter
To solve this, I went in the file execution.py and commented the row from timing import clock. In your machine this file is in the folder:
c:\users\chinmay\appdata\local\programs\python\python38-32\lib\site-packages\IPython\core\magics\
try this:
conda update --force conda
conda update ipython
I uninsatlled and installed the jupyter from conda..Worked fine for me

Conda crashes after installing one package - OSError: /lib64/liblzma.so.5: version `XZ_5.2' not found

I used coda for a long time, with limited problems.
However, I recently installed Miniconda2 (Miniconda2-latest-Linux-x86_64.sh) on a HPC node.
Everything works fine, but I can not install multiple packages.
What happens, is that I install one package, and after that, I get the following error when I try to install a new one:
Traceback (most recent call last):
File "/hpc-home/ro/miniconda2/bin/conda", line 13, in <module>
sys.exit(main())
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/cli/main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1335, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1046, in __call__
return self.handle_exception(exc_val, exc_tb)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1090, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1101, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/exceptions.py", line 1171, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/cli/main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/core/index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda/core/package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/conda_package_handling/api.py", line 3, in <module>
from libarchive.exception import ArchiveError as _LibarchiveArchiveError
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/libarchive/__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/libarchive/entry.py", line 6, in <module>
from . import ffi
File "/hpc-home/ro/miniconda2/lib/python2.7/site-packages/libarchive/ffi.py", line 27, in <module>
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "/hpc-home/ro/miniconda2/lib/python2.7/ctypes/__init__.py", line 444, in LoadLibrary
return self._dlltype(name)
File "/hpc-home/ro/miniconda2/lib/python2.7/ctypes/__init__.py", line 366, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /lib64/liblzma.so.5: version `XZ_5.2' not found (required by /hpc-home/ro/miniconda2/lib/libarchive.so.13)
The problem is temporally fixed when I re-install conda:
bash Miniconda2-latest-Linux-x86_64.sh -u
I am not sure what I am missing here. Would someone point me towards a potential solution not involving using sudo, as I have no rights?

Categories

Resources