VSCode debugger can not import queue due to shadowing - python

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

Related

No longer able to install python packages with pip `ImportError: DLL load failed while importing _socket: %1 is not a valid Win32 application`

Using Windows 10
This is a new problem and I am unsure what change caused it. I have always succesfully used pip before. When I try to do a pip install I always receive this exact error:
Traceback (most recent call last):
File "c:\program files (x86)\python38-32\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files (x86)\python38-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files (x86)\Python38-32\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\program files (x86)\python38-32\lib\site-packages\pip\_internal\cli\main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "c:\program files (x86)\python38-32\lib\site-packages\pip\_internal\cli\autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "c:\program files (x86)\python38-32\lib\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "c:\program files (x86)\python38-32\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "c:\program files (x86)\python38-32\lib\site-packages\pip\_internal\cli\progress_bars.py", line 12, in <module>
from pip._internal.utils.logging import get_indentation
File "c:\program files (x86)\python38-32\lib\site-packages\pip\_internal\utils\logging.py", line 9, in <module>
import logging.handlers
File "c:\program files (x86)\python38-32\lib\logging\handlers.py", line 26, in <module>
import logging, socket, os, pickle, struct, time, re
File "c:\program files (x86)\python38-32\lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed while importing _socket: %1 is not a valid Win32 application.
What is causing this error and how do I fix it?
[Not enough reputation to comment, but] You're missing a directory from the %PATH% environment variable. You need to add the Python base DLL location to your path variable, but you'll need another person to give you details.
Edit: You're probably missing the cuda\bin subdirectory in your %PATH% variable. Google should help you figure out how to resolve that.

Unable to access Jupyter Notebook. ImportError: DLL load failed: %1 is not a valid Win32 application

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.

Spyder :An error ocurred while starting the kernel

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.

gevent loading failure: DLL load failed inside venv

I'm currently using venv and gevent inside my python environment, and I can't seem to get it to work. Here's my stack trace:
Traceback (most recent call last):
File "C:\Users\Brian\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Brian\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Projects\sfe-giveaways\venv\lib\site-packages\disco\cli.py", line 12, in <module>
from gevent import monkey
File "D:\Projects\sfe-giveaways\venv\lib\site-packages\gevent\__init__.py", line 48, in <module>
import socket # pylint:disable=unused-import,useless-suppression
File "C:\Users\Brian\AppData\Local\Programs\Python\Python35\lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.
I believe that I need a 32-bit version of gevent so it's compatible with venv, but I don't know how to install the 32-bit version. Thanks in advance.

openSSL error in Scrapy while creating project

I have just installed scrapy and all the things along with it as per from scrapy tutorial site.
When I create project using Scrapy with such command
scrapy startproject [projectname]
so it gives me following error
Traceback (most recent call last):
File "c:\python\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python\Python27\Scripts\scrapy.exe\__main__.py", line 9, in <module>
File "c:\python\python27\lib\site-packages\scrapy\cmdline.py", line 122, in execute
cmds = _get_commands_dict(settings, inproject)
File "c:\python\python27\lib\site-packages\scrapy\cmdline.py", line 46, in _get_commands_dict
cmds = _get_commands_from_module('scrapy.commands', inproject)
File "c:\python\python27\lib\site-packages\scrapy\cmdline.py", line 29, in _get_commands_from_module
for cmd in _iter_command_classes(module):
File "c:\python\python27\lib\site-packages\scrapy\cmdline.py", line 20, in _iter_command_classes
for module in walk_modules(module_name):
File "c:\python\python27\lib\site-packages\scrapy\utils\misc.py", line 71, in walk_modules
submod = import_module(fullpath)
File "c:\python\python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "c:\python\python27\lib\site-packages\scrapy\commands\version.py", line 6, in <module>
import OpenSSL
ImportError: No module named OpenSSL
After that even I tried to install openSSl manually using pip
but it saying that package is already installed
Help me with it.
You can satisfy the missing dependency by doing the following:
You need to install OpenSSL binaries on your system. Get binaries
from here: https://wiki.openssl.org/index.php/Binaries
Then you need to install pyOpenSSL, from here: https://pypi.python.org/pypi/pyOpenSSL/0.13

Categories

Resources