When I run the code below, a long time will appear this kind of error.
code:
from gevent import monkey; monkey.patch_all()
from gevent.pywsgi import WSGIServer
sys.modules.pop("threading", None)
Exception info:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py", line 375, in _notify_links
link(self)
File "/usr/local/lib/python2.7/dist-packages/gevent/threading.py", line 22, in _cleanup
__threading__._active.pop(id(g))
KeyError: 40406544
(<function _cleanup at 0x1fed0c8>, <Greenlet at 0x2688e10>) failed with KeyError
Related
Whenever I try to open any apps on anaconda navigator (such as Spyder), I get this message. I am almost sure that is a problem with the path but I cannot resolve it.
Traceback (most recent call last):
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\utils.py", line 281, in create_window
main.setup()
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 772, in setup
from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\plugins\help\utils\sphinxify.py", line 34, in
from jinja2 import Environment, FileSystemLoader
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\__init__.py", line 12, in
from .environment import Environment
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\environment.py", line 25, in
from .defaults import BLOCK_END_STRING
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\defaults.py", line 3, in
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\filters.py", line 13, in
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (C:\Users\Windows\anaconda3\lib\site-packages\markupsafe\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Windows\anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\start.py", line 237, in main
mainwindow.main(options, args)
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1992, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\utils.py", line 283, in create_window
if main.console is not None:
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1088, in __getattr__
return self.get_plugin(self._INTERNAL_PLUGINS_MAPPING[attr])
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 165, in get_plugin
raise SpyderAPIError(f'Plugin "{plugin_name}" not found!')
spyder.api.exceptions.SpyderAPIError: Plugin "internal_console" not found!
I want to create tasks programatically inside the running loop. Every second will be check if some tasks are currently not running (sometimes because of exceptions) the should be started. For simplicity reasons here ist only the loop.
import asyncio
async def parent_coro():
await child_coro()
async def child_coro():
await asyncio.sleep(1)
raise Exception('OMG!')
async def main():
tasks = []
while True:
task = asyncio.create_task(parent_coro()),
tasks.append(task)
await asyncio.sleep(1)
# This cannot be reached
done, pending = await asyncio.wait(tasks)
for task in done:
try:
print(task.exception())
except Exception:
print('You will not see me!')
if __name__ == '__main__':
asyncio.run(main())
The problem is that this Tasks cannot be awaited, and when I stop the process (Ctrl+C) I get Task exception was never retrieved. Here the stacktrace:
^CTraceback (most recent call last):
File "/tmp/check.py", line 33, in <module>
asyncio.run(main())
File "/home/antonio/.pyenv/versions/3.9.6/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/antonio/.pyenv/versions/3.9.6/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete
self.run_forever()
File "/home/antonio/.pyenv/versions/3.9.6/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
self._run_once()
File "/home/antonio/.pyenv/versions/3.9.6/lib/python3.9/asyncio/base_events.py", line 1854, in _run_once
event_list = self._selector.select(timeout)
File "/home/antonio/.pyenv/versions/3.9.6/lib/python3.9/selectors.py", line 469, in select
fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt
Task exception was never retrieved
future: <Task finished name='Task-6' coro=<parent_coro() done, defined at /home/myproject/check.py:4> exception=Exception('OMG!')>
Traceback (most recent call last):
File "/tmp/check.py", line 5, in parent_coro
await child_coro()
File "/tmp/check.py", line 10, in child_coro
raise Exception('OMG!')
Exception: OMG!
Task exception was never retrieved
future: <Task finished name='Task-5' coro=<parent_coro() done, defined at /tmp/check.py:4> exception=Exception('OMG!')>
Traceback (most recent call last):
File "/tmp/check.py", line 5, in parent_coro
await child_coro()
File "/tmp/check.py", line 10, in child_coro
raise Exception('OMG!')
Exception: OMG!
Task exception was never retrieved
future: <Task finished name='Task-4' coro=<parent_coro() done, defined at /tmp/check.py:4> exception=Exception('OMG!')>
Traceback (most recent call last):
File "/tmp/check.py", line 5, in parent_coro
await child_coro()
File "/tmp/check.py", line 10, in child_coro
raise Exception('OMG!')
Exception: OMG!
Task exception was never retrieved
future: <Task finished name='Task-3' coro=<parent_coro() done, defined at /home/myproject/check.py:4> exception=Exception('OMG!')>
Traceback (most recent call last):
File "/home/myproject/check.py", line 5, in parent_coro
await child_coro()
File "/home/myproject/check.py", line 10, in child_coro
raise Exception('OMG!')
Exception: OMG!
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<parent_coro() done, defined at /home/myproject/check.py:4> exception=Exception('OMG!')>
Traceback (most recent call last):
File "/home/myproject/check.py", line 5, in parent_coro
await child_coro()
File "/home/myproject/check.py", line 10, in child_coro
raise Exception('OMG!')
Exception: OMG!
There is now way for your code to exit the while loop.
As a solution, you can inspect your tasks inside the while loop. Your tasks will then be inspected every second.
async def main():
tasks = []
while True:
task = asyncio.create_task(parent_coro()),
tasks.append(task)
await asyncio.sleep(1)
done, pending = await asyncio.wait(tasks)
for task in done:
try:
print(task.exception())
except Exception:
print('You will not see me!)
You could also create a background task launching parent_coro tasks every second. In this case, once this task is launched, you could check tasks whenever you want.
I am trying to test the sphinx extension TODO from https://sphinx.readthedocs.io/en/master/development/tutorials/todo.html#writing-the-extension
However, this import "from docutils.parsers.rst import SphinxDirective" does not work, giving "Extension error:
Could not import extension todo (exception: No module named SphinxDirective)
"
I tried python2 and python3 , and readthedocs environment.
the code is here, https://www.sphinx-doc.org/en/master/development/tutorials/todo.html#writing-the-extension
ReadTheDocs gives this message:
Running Sphinx v1.8.5
loading translations [en]... done
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 472, in load_extension
mod = __import__(extname, None, None, ['setup'])
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/checkouts/latest/docs/todo.py", line 6, in <module>
from docutils.parsers.rst import SphinxDirective
ImportError: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 303, in build_main
args.tags, args.verbosity, args.jobs, args.keep_going)
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 228, in __init__
self.setup_extension(extension)
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 449, in setup_extension
self.registry.load_extension(self, extname)
File "/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 475, in load_extension
raise ExtensionError(__('Could not import extension %s') % extname, err)
sphinx.errors.ExtensionError: Could not import extension todo (exception: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py))
Extension error:
Could not import extension todo (exception: cannot import name 'SphinxDirective' from 'docutils.parsers.rst' (/home/docs/checkouts/readthedocs.org/user_builds/demo-sphinx-extensions-for-dirac/envs/latest/lib/python3.7/site-packages/docutils/parsers/rst/__init__.py))
Well,
one has to use proper files from the tutorial, https://www.sphinx-doc.org/en/master/development/tutorials/todo.html , together with all installed packages.
This is ensured on the ReadTheDocs portal, where the extension buildup works well.
PS: Files and links are https://github.com/miroi/demo-sphinx-extensions-for-DIRAC
I am trying to use rqt_graph in ROS kinetic and I am getting the following error. I am not sure what is causing it and have no idea how to fix it.
It seems to be a problem with an undefined symbole but not sure how this would happen.
rosrun rqt_graph rqt_graph
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/rqt_graph/rqt_graph", line 8, in <module>
sys.exit(main.main(sys.argv, standalone='rqt_graph.ros_graph.RosGraph'))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_gui/main.py", line 59, in main
return super(Main, self).main(argv, standalone=standalone, plugin_argument_provider=plugin_argument_provider, plugin_manager_settings_prefix=str(hash(os.environ['ROS_PACKAGE_PATH'])))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/main.py", line 340, in main
from python_qt_binding import QT_BINDING
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/__init__.py", line 55, in <module>
from .binding_helper import loadUi, QT_BINDING, QT_BINDING_MODULES, QT_BINDING_VERSION # #UnusedImport
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 252, in <module>
getattr(sys, 'SELECT_QT_BINDING_ORDER', None),
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 98, in _select_qt_binding
raise ImportError("Could not find Qt binding (looked for: %s):\n%s" % (', '.join(["'%s'" % b for b in binding_order]), '\n'.join(error_msgs)))
ImportError: Could not find Qt binding (looked for: 'pyqt', 'pyside'):
ImportError for 'pyqt': /usr/lib/python2.7/dist-packages/PyQt5/QtCore.x86_64-linux-gnu.so: undefined symbol: _ZTI13QFileSelector
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 89, in _select_qt_binding
QT_BINDING_VERSION = binding_loader(required_modules, optional_modules)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 131, in _load_pyqt
_named_import('PyQt5.%s' % module_name)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 111, in _named_import
module = builtins.__import__(name)
ImportError: /usr/lib/python2.7/dist-packages/PyQt5/QtCore.x86_64-linux-gnu.so: undefined symbol: _ZTI13QFileSelector
ImportError for 'pyside': /usr/lib/x86_64-linux-gnu/libQt5Network.so.5: undefined symbol: _ZN16QLoggingCategoryD1Ev
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 89, in _select_qt_binding
QT_BINDING_VERSION = binding_loader(required_modules, optional_modules)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 163, in _load_pyside
_named_import('PySide2.%s' % module_name)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 111, in _named_import
module = builtins.__import__(name)
ImportError: /usr/lib/x86_64-linux-gnu/libQt5Network.so.5: undefined symbol: _ZN16QLoggingCategoryD1Ev
code here
From What I can See In The Log Your pyqt and main Qt5 libs are missing And It's Not ROS Based Error
I Suggest You Install Or Reinstall Those Libs and Make Sure That Python Can Find Them
I have been trying to find a way to update the GUI thread from a Python thread outside of main. The PyQt5 docs on sourceforge have good instructions on how to do this. But I still can't get things to work.
Is there a good way to explain the following output from an interactive session? Shouldn't there be a way to call the emit method on these objects?
>>> from PyQt5.QtCore import QObject, pyqtSignal
>>> obj = QObject()
>>> sig = pyqtSignal()
>>> obj.emit(sig)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'QObject' object has no attribute 'emit'
and
>>> obj.sig.emit()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'QObject' object has no attribute 'sig'
and
>>> obj.sig = pyqtSignal()
>>> obj.sig.emit()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'PyQt5.QtCore.pyqtSignal' object has no attribute 'emit'
Following words and codes are in PyQt5 docs.
New signals should only be defined in sub-classes of QObject.They must be part of the class definition and cannot be dynamically added as class attributes after the class has been defined.
from PyQt5.QtCore import QObject, pyqtSignal
class Foo(QObject):
# Define a new signal called 'trigger' that has no arguments.
trigger = pyqtSignal()
def connect_and_emit_trigger(self):
# Connect the trigger signal to a slot.
self.trigger.connect(self.handle_trigger)
# Emit the signal.
self.trigger.emit()
def handle_trigger(self):
# Show that the slot has been called.
print "trigger signal received"