The ipython console is constantly throwing this error and I tried :
updating spyder
Uninstalling and reinstalling anaconda
Reading people's response on how they tried to fix it
But still I could not fix this.
Traceback (most recent call last):
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\spyder_kernels\console\__main__.py", line 11, in
start.main()
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\spyder_kernels\console\start.py", line 287, in main
import_spydercustomize()
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\spyder_kernels\console\start.py", line 39, in import_spydercustomize
import spydercustomize
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\spyder_kernels\customize\spydercustomize.py", line 27, in
from IPython.core.getipython import get_ipython
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\IPython\__init__.py", line 54, in
from .core.application import Application
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\IPython\core\application.py", line 23, in
from traitlets.config.application import Application, catch_config_error
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\traitlets\config\__init__.py", line 6, in
from .application import *
File "C:\Users\bbachegowda\AppData\Local\Continuum\anaconda3\lib\site‑packages\traitlets\config\application.py", line 10, in
import json
File "C:\Users\bbachegowda\json.py", line 12
source = response.read()
^
IndentationError: expected an indented block
The module name resolution is described in https://docs.python.org/3/tutorial/modules.html#the-module-search-path:
When a module named spam is imported, the interpreter first searches
for a built-in module with that name. If not found, it then searches
for a file named spam.py in a list of directories given by the
variable sys.path.
It looks like for some reason, the built-in module json is not found and that python looks into the path where C:\Users\bbachegowda\json.py is. So you should reinstall python to fix the built-in module json.
Had the same problem with Spyder when installing WinPython, version: WPy64-3.7.4.1.
However previous version: WPy64-3.7.4.0 works fine.
Related
When I try to run any python code in debug mode using VScode, I got an error message saying:
42737 -- /home/<username>/Desktop/development/bopi/experiment_handler.py .vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/launcher 4
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module>
from debugpy.server import cli
File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module>
import debugpy._vendored.force_pydevd # noqa
File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 37, in <module>
pydevd_constants = import_module('_pydevd_bundle.pydevd_constants')
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py", line 362, in <module>
from _pydev_bundle._pydev_saved_modules import thread, threading
File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py", line 97, in <module>
import queue as _queue; verify_shadowed.check(_queue, ['Queue', 'LifoQueue', 'Empty', 'Full', 'deque'])
File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py", line 75, in check
raise DebuggerInitializationError(msg)
_pydev_bundle._pydev_saved_modules.DebuggerInitializationError: It was not possible to initialize the debugger due to a module name conflict.
i.e.: the module "queue" could not be imported because it is shadowed by:
/home/<username>/.local/lib/python2.7/site-packages/queue/__init__.pyc
Please rename this file/folder so that the original module from the standard library can be imported.
Deleting the init.pyc and init.py resulting with an error message about missing queue import.
Downgrading my Python extension in Visual Studio Code to v2022.2.1924087327 worked for me.
Elevating #Onur Berk's comment below as part of the answer:
Its is very easy to downgrade the python extension, just click 'extensions' and find the Python extension and select it. Rather than clicking 'uninstall' click the arrow next to it, this will give you an option to install another version
When I am trying to run the spyder (Anaconda) I am getting the following Error:
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 205, in main
mainwindow.main()
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3651, in main
mainwindow = run_spyder(app, options, args)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3526, in run_spyder
main.setup()
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 945, in setup
from spyder.plugins.ipythonconsole.plugin import IPythonConsole
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\plugin.py", line 46, in
from spyder.plugins.ipythonconsole.widgets import (ClientWidget,
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\__init__.py", line 16, in
from .debugging import DebuggingWidget
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\debugging.py", line 13, in
import pdb
File "C:\ProgramData\Anaconda3\lib\pdb.py", line 138, in
class Pdb(bdb.Bdb, cmd.Cmd):
AttributeError: module 'cmd' has no attribute 'Cmd'
Can someone please health me to resolve this issue?
I have created a file with the name cmd.py. After deleting the file (or rename the file), my problem got solved.
Do you happen to have a file named cmd.py in the same directory as the file you are trying to execute?
Cause If you are, then import cmd would not import the right python module. Instead, it would import your created "cmd.py" file.
I too faced this issue cause I had a file named "cmd.py" along with my python scripts and it would import that whenever I said import cmd. Renaming it helped me solve the issue
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
I am trying to open Jupyter Notebook in my Windows10 system.
I had python2.7 initially in my machine and I have installed python 3.8.
I have also installed Jupyter Notebook using pip install Jupyter
The installation has been successful, but when I try to access Jupyter Notebook, I get this error:
C:\Users\abhishek murahari>jupyter notebook
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\jupyter-notebook.EXE\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\notebook\notebookapp.py", line 47, in <module>
from zmq.eventloop import ioloop
File "c:\python27\lib\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "c:\python27\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "c:\python27\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "c:\python27\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "c:\python27\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed: %1 is not a valid Win32 application.
Please help me with a solution.
Please check if the python version you are using is also 32 bit. If not then that could be the issue. You would be using a 64 bit python version.
Why I can't install pip with pypy3 -m ensurepip? I have unpacked PyPy from official package, and followed instructions at official docs but resulting in an error. Interpreter log is below.
Traceback (most recent call last):
File "D:\pypy3-v5.10.0-win32\lib-python\3\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\pypy3-v5.10.0-win32\lib-python\3\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\pypy3-v5.10.0-win32\lib-python\3\ensurepip\__main__.py", line 4, in <module>
ensurepip._main()
File "D:\pypy3-v5.10.0-win32\lib-python\3\ensurepip\__init__.py", line 209, in _main
default_pip=args.default_pip,
File "D:\pypy3-v5.10.0-win32\lib-python\3\ensurepip\__init__.py", line 116, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "D:\pypy3-v5.10.0-win32\lib-python\3\ensurepip\__init__.py", line 40, in _run_pip
import pip
File "C:\Users\user\AppData\Local\Temp\tmp5zq6hqua\pip-9.0.1-py2.py3-none-any.whl\pip\__init__.py", line 21, in <module>
File "C:\Users\user\AppData\Local\Temp\tmp5zq6hqua\pip-9.0.1-py2.py3-none-any.whl\pip\_vendor\requests\__init__.py", line 62, in <module>
File "C:\Users\user\AppData\Local\Temp\tmp5zq6hqua\pip-9.0.1-py2.py3-none-any.whl\pip\_vendor\requests\packages\__init__.py", line 27, in <module>
File "C:\Users\user\AppData\Local\Temp\tmp5zq6hqua\pip-9.0.1-py2.py3-none-any.whl\pip\_vendor\requests\packages\urllib3\__init__.py", line 8, in <module>
File "C:\Users\user\AppData\Local\Temp\tmp5zq6hqua\pip-9.0.1-py2.py3-none-any.whl\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 101, in <module>
AttributeError: module 'errno' has no attribute 'EWOULDBLOCK'
The errno module on pypy3 on Windows (which is beta) is indeed incomplete. This has been fixed after the 5.10.0 release and will be included in the 5.10.1 release.
We build nightly zip files off the latest HEAD, available here. It would be great if you could try out the latest windows version and let us know on IRC at #pypy, or on the pypy-dev mailing list, or by filing an issue on our bitbucket issue tracker whether it works for you, so that we will not need to do a 5.10.2 bug release fix after the current one.