AttributeError when running rqt commands - python

I am trying to use rqt in ROS hydro but I see the following errors:
Traceback (most recent call last): File
"/opt/ros/hydro/bin/rqt_graph", line 8, in
sys.exit(main.main(sys.argv, standalone='rqt_graph.ros_graph.RosGraph')) File
"/opt/ros/hydro/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/hydro/lib/python2.7/dist-packages/qt_gui/main.py", line
336, in main
from python_qt_binding import QT_BINDING File "/opt/ros/hydro/lib/python2.7/dist-packages/python_qt_binding/init.py",
line 55, in
from .binding_helper import loadUi, QT_BINDING, QT_BINDING_MODULES, QT_BINDING_VERSION # #UnusedImport File
"/opt/ros/hydro/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py",
line 265, in
getattr(sys, 'SELECT_QT_BINDING_ORDER', None), File "/opt/ros/hydro/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py",
line 84, in _select_qt_binding
QT_BINDING_VERSION = binding_loader(required_modules, optional_modules) File
"/opt/ros/hydro/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py",
line 139, in _load_pyqt
_named_import('PyQt4.%s' % module_name) File "/opt/ros/hydro/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py",
line 106, in _named_import
module = builtins.import(name) AttributeError: 'module' object has no attribute 'import'

Related

Error while creating graph from input of type "<class 'dgl.subgraph.DGLSubGraph'>"

I am running the code from this repository Link with dgl==0.1.3 and I am facing this error. I am not sure why its coming. I have attached the code snippet and the error below.
code snippet
def _prepare_subgraphs(self, nodes, r_label, n_labels):
subgraph = dgl.DGLGraph(self.graph.subgraph(nodes))
Error
Traceback (most recent call last):
File "train.py", line 222, in <module>
main(params)
File "train.py", line 32, in main
kge_model=params.kge_model, file_name=params.train_file)
File "/home2/harsha.vasamsetti/SumGNN-master_olddgl/subgraph_extraction/datasets.py", line 142, in __init__
self.__getitem__(0)
File "/home2/harsha.vasamsetti/SumGNN-master_olddgl/subgraph_extraction/datasets.py", line 150, in __getitem__
subgraph_pos = self._prepare_subgraphs(nodes_pos, r_label_pos, n_labels_pos)
File "/home2/harsha.vasamsetti/SumGNN-master_olddgl/subgraph_extraction/datasets.py", line 159, in _prepare_subgraphs
subgraph = dgl.DGLGraph(self.graph.subgraph(nodes))
File "/home2/harsha.vasamsetti/.miniconda3/envs/sumgnn=0.1.3/lib/python3.7/site-packages/dgl/graph.py", line 181, in __init__
self._graph = create_graph_index(graph_data, multigraph, readonly)
File "/home2/harsha.vasamsetti/.miniconda3/envs/sumgnn=0.1.3/lib/python3.7/site-packages/dgl/graph_index.py", line 925, in create_graph_index
% type(graph_data))
dgl._ffi.base.DGLError: Error while creating graph from input of type "<class 'dgl.subgraph.DGLSubGraph'>".

Getting weird error on running python in cmd then continue normally

When I run python on cmd I get this weird error:
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site.py", line 446, in register_readline
import readline
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\readline.py", line 34, in <module>
rl = Readline()
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\rlmain.py", line 422, in __init__
BaseReadline.__init__(self)
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\rlmain.py", line 62, in __init__
mode.init_editing_mode(None)
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\modes\emacs.py", line 633, in init_editing_mode
self._bind_key('space', self.self_insert)
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\modes\basemode.py", line 162, in _bind_key
if not callable(func):
File "C:\Users\Khaled\AppData\Local\Programs\Python\Python310\lib\site-packages\pyreadline\py3k_compat.py", line 8, in callable
return isinstance(x, collections.Callable)
AttributeError: module 'collections' has no attribute 'Callable'
But then I continue using python normally:
>>>
I did not find any effects of this problem python is running normally but I do not want it to appear and to know what does it do.

ImportError: cannot import name 'dump_csp_header' from 'werkzeug.http' (C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\http.py)

I am getting this error by running tenserbord
(base) C:\Users\karan\TF_2_Notebooks_and_Data\03-ANNs>tensorboard
--logdir logs\fit Traceback (most recent call last): File "C:\Users\karan\Anaconda3\Scripts\tensorboard-script.py", line 5, in
from tensorboard.main import run_main File "C:\Users\karan\Anaconda3\lib\site-packages\tensorboard\main.py", line
40, in
from tensorboard import default File "C:\Users\karan\Anaconda3\lib\site-packages\tensorboard\default.py",
line 38, in
from tensorboard.plugins.audio import audio_plugin File "C:\Users\karan\Anaconda3\lib\site-packages\tensorboard\plugins\audio\audio_plugin.py",
line 23, in
from werkzeug import wrappers File "C:\Users\karan\Anaconda3\lib\site-packages\werkzeug__init__.py",
line 151, in
import('werkzeug.exceptions') File "C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\exceptions.py",
line 71, in
from werkzeug.wrappers import Response File "C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\wrappers__init__.py",
line 26, in
from .common_descriptors import CommonRequestDescriptorsMixin File
"C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\wrappers\common_descriptors.py",
line 7, in
from ..http import dump_csp_header ImportError: cannot import name 'dump_csp_header' from 'werkzeug.http'
(C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\http.py)
and also by running,
board = TensorBoard(log_dir=log_directory,histogram_freq=1,
write_graph=True,
write_images=True,
update_freq='epoch',
profile_batch=2,embeddings_freq=1)
if I put embeddings_freq=1 instead of embeddings_freq=0 then I get an error
Train on 426 samples, validate on 143 samples Traceback (most recent
call last):
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorflow_core\python\keras\callbacks.py",
line 1561, in _configure_embeddings
from tensorboard.plugins import projector
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorboard\plugins\projector__init__.py",
line 32, in
from tensorboard.plugins.projector import projector_plugin as _projector_plugin
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorboard\plugins\projector\projector_plugin.py",
line 30, in
from werkzeug import wrappers
File
"C:\Users\karan\Anaconda3\lib\site-packages\werkzeug__init__.py",
line 151, in
import('werkzeug.exceptions')
File
"C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\exceptions.py",
line 71, in
from werkzeug.wrappers import Response
File
"C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\wrappers__init__.py",
line 26, in
from .common_descriptors import CommonRequestDescriptorsMixin
File
"C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\wrappers\common_descriptors.py",
line 7, in
from ..http import dump_csp_header
ImportError: cannot import name 'dump_csp_header' from 'werkzeug.http'
(C:\Users\karan\Anaconda3\lib\site-packages\werkzeug\http.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 5, in
callbacks=[board,early_stop]
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training.py",
line 819, in fit
use_multiprocessing=use_multiprocessing)
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py",
line 307, in fit
mode=ModeKeys.TRAIN)
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorflow_core\python\keras\callbacks.py",
line 107, in configure_callbacks
callback_list.set_model(callback_model)
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorflow_core\python\keras\callbacks.py",
line 222, in set_model
callback.set_model(model)
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorflow_core\python\keras\callbacks.py",
line 1549, in set_model
self._configure_embeddings()
File
"C:\Users\karan\Anaconda3\lib\site-packages\tensorflow_core\python\keras\callbacks.py",
line 1563, in _configure_embeddings
raise ImportError('Failed to import TensorBoard. Please make sure that '
ImportError: Failed to import TensorBoard. Please make sure that
TensorBoard integration is complete."
What should I do> I am not an expert just a beginner, and I didn't create an anaconda env, I am running it in a (base), can someone please reply it fast? My exams are coming and I need to resolve this as fast it could be, my thanks to the community.

what is the replacement of wikipedia.getSite()? or is it still usable?

I ran a pywikibot sample code,
but it is aborted due to AttributeError.
Traceback is ...
Traceback (most recent call last):
File "pwb.py", line 270, in <module>
if not main():
File "pwb.py", line 264, in main
run_python_file(filename, [filename] + args, argvu, file_package)
File "pwb.py", line 109, in run_python_file
main_mod.__dict__)
File ".\cochonBot.py", line 81, in <module>
main()
File ".\cochonBot.py", line 52, in main
stub_list = cat_list_rec(u'遺꾨쪟:?좊쭑湲 遺꾨쪟', stub_ignore_cats)
File ".\cochonBot.py", line 14, in cat_list_rec
cat = catlib.Category(wikipedia.getSite(), top_cat)
AttributeError: 'module' object has no attribute 'getSite'
<type 'exceptions.AttributeError'>
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort
what is the replacement of wikipedia.getSite()? or is it still usable?
You can simply use pywikibot.Site() instead.

Open a new instance of AutoCAD via Python

Does anyone have any experience using Python with AutoCAD? I'm just trying, as a test to see if I can open a new instance of AutoCAD via Python and though that PyAutocad worked well (feel free to offer other suggestions, if you have any).
Anyway based on the doc (https://pypi.python.org/pypi/pyautocad/#downloads) - it says these lines of code should do it, but nothing's happened as of yet.
from pyautocad import Autocad, APoint
acad = Autocad()
acad.prompt("Hello, Autocad from Python\n")
Just these lines of code should generate info on the commandline but instead results in about 50 lines worth of traceback (which I can post as well if anyone's interested) - any ideas?
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
acad.prompt("Hello, Autocad")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 54, in app
self._app = comtypes.client.GetActiveObject('AutoCAD.Application')
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 180, in GetActiveObject
obj = comtypes.GetActiveObject(clsid, interface=interface)
File "C:\Python27\lib\site-packages\comtypes\__init__.py", line 1165, in GetActiveObject
oledll.oleaut32.GetActiveObject(byref(clsid), None, byref(p))
File "_ctypes/callproc.c", line 941, in GetResult
WindowsError: [Error -2147221021] Operation unavailable
After adding the VBA Module, the traceback now reads:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
acad.prompt("Hello")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 54, in app
self._app = comtypes.client.GetActiveObject('AutoCAD.Application')
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 183, in GetActiveObject
return _manage(obj, clsid, interface=interface)
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Python27\lib\site-packages\comtypes\client\__init__.py", line 112, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: 'module' object has no attribute 'IAcadApplication'
Now after deleting comtypes' "gen" folder per #reclosedev, Autocad now opens but the string of text still will not appear on the command line - the traceback reads:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
acad.prompt("Hello")
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 153, in prompt
self.doc.Utility.Prompt(u"%s\n" % text)
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 65, in doc
return self.app.ActiveDocument
File "C:\Python27\lib\site-packages\pyautocad\api.py", line 59, in app
self._app.Visible = self._visible
File "C:\Python27\lib\site-packages\comtypes\client\dynamic.py", line 116, in __setattr__
dispid = self._comobj.GetIDsOfNames(name)[0]
File "C:\Python27\lib\site-packages\comtypes\automation.py", line 643, in GetIDsOfNames
self.__com_GetIDsOfNames(riid_null, arr, len(names), lcid, ids)
COMError: (-2147418111, 'Call was rejected by callee.', (None, None, None, 0, None))
Have you considered IronPython?
http://through-the-interface.typepad.com/through_the_interface/2009/03/using-ironpython-with-autocad.html
Here's a quick example of how it could be leveraged:
import clr
import System
from System import Type, Activator
acApp = Activator.CreateInstance(Type.GetTypeFromProgID("AutoCAD.Application"))
acApp.Visible = 1
acApp.ActiveDocument.SendCommand("(Princ \"Hello World from Python!\")(Princ)\n")
Obviously the ProgId will correspond to whichever version of AutoCAD was opened last.

Categories

Resources