I am trying to use PyQt's Resource System but it appears I have no clue what I am doing! I already have to application created, along with its GUI I am just trying to import some images to use with the program.
I used the QtDesigner to create the resource file and I compiled it using pyrcc4.exe. But when I attempt to import the resource file I get this error:
Traceback (most recent call last):
File "C:\Projects\main.py", line 14, in <module>
import main_rc
File "C:\Projects\main_rc.py", line 482, in <module>
qInitResources()
File "C:\Projects\main_rc.py", line 477, in qInitResources
QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
TypeError: argument 2 of qRegisterResourceData() has an invalid type
What am I doing wrong?
pyrcc generates Python 2.x code by default.
Try regenerating your resource files using pyrcc with flag '-py3'
Related
code:
import ColabTurtle.Turtle as tutel
tutel.initializeTurtle()
tutel.forward(10)
error is:
<IPython.core.display.HTML object>
Traceback (most recent call last):
File "f:\stuff\e.py", line 3, in <module>
tutel.forward(10)
File "C:\Users\U.S.E.R\AppData\Local\Programs\Python\Python311\Lib\site-packages\ColabTurtle\Turtle.py", line 174, in forward
_moveToNewPosition(ending_point)
File "C:\Users\U.S.E.R\AppData\Local\Programs\Python\Python311\Lib\site-packages\ColabTurtle\Turtle.py", line 163, in _moveToNewPosition
_updateDrawing()
File "C:\Users\U.S.E.R\AppData\Local\Programs\Python\Python311\Lib\site-packages\ColabTurtle\Turtle.py", line 144, in _updateDrawing
raise AttributeError("Display has not been initialized yet. Call initializeTurtle() before using.")
AttributeError: Display has not been initialized yet. Call initializeTurtle() before using.
basically, it tells me to use intializeturtle() before running a ColabTurtle function. Except, i did already use it.
Help.
Try to run it in Google Collab. If there will be no module ColabTurtle, you need to create a new code (+code) and write
!pip install ColabTurtle
I am trying to import UserNotifications from the PushKit framework but i don't know how to call it because the only Include function i know of in pyobjus is AppKit. I have not seen of any way to call frameworks from the PushKit when i try to call it from the AppKit. it returns an error. Below is my code and the error. I would appreciate any help.
from pyobjus import autoclass
from pyobjus.dylib_manager import load_framework, INCLUDE
load_framework(INCLUDE.AppKit)
UserNotifications = autoclass('UserNotifications')
Traceback
Traceback (most recent call last):
File "/Users/temitayoadefemi/PycharmProjects/test7/mainfile.py", line 5, in <module>
UserNotifications = autoclass('UserNotifications')
File "pyobjus/pyobjus.pyx", line 726, in pyobjus.autoclass
File "pyobjus/pyobjus.pyx", line 85, in pyobjus.MetaObjcClass.__new__
File "pyobjus/pyobjus.pyx", line 116, in pyobjus.MetaObjcClass.resolve_class
pyobjus.ObjcException: Unable to find class b'UserNotifications'
AppKit doesn't have a class called UserNotifications. You could use UNNotificationSettings for normal Push Notification or PKPushRegistry for VoIP Push Notification.
References:
https://developer.apple.com/documentation/pushkit?language=objc
https://developer.apple.com/documentation/usernotifications?language=objc
I've got PyPDF2 lib from here:
https://github.com/mstamy2/PyPDF2/tree/Python3-3
When trying to run script "Example 1:" from from there see it:
PyPDF2 python versions (2.5 - 3.3) compatibility branch
Traceback (most recent call last):
File "1.py", line 6, in <module>
input1 = PdfFileReader(open("document1.pdf", "rb"))
File "C:\Python33\lib\site-packages\PyPDF2\pdf.py", line 595, in __init__
self.read(stream)
File "C:\Python33\lib\site-packages\PyPDF2\pdf.py", line 1097, in read
streamData = StringIO(xrefstream.getData())
TypeError: initial_value must be str or None, not bytes
What is wrong?
It was a problem related to the compatibility within PyPDF2 and Python 3.
In my case, I have solved it by replacing pdf.py and utils.py with the ones you will find here, where they basically control if you are running Python 3 and, in case you are, receive data as bytes instead of strings.
I'm learning Xpath and XSLT using Python 2.6.6-64bit on my unix workstation. For Xpath, I'm using the xpath module provided in PyXml-0.8.4.
However, the import line itself throws the following error:
Traceback (most recent call last):
File "xp.py", line 7, in <module>
from xml.xpath import Evaluate
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/__init__.py", line 112, in <module>
from pyxpath import ExprParserFactory
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/pyxpath.py", line 59, in <module>
from xml.xpath.ParsedAbbreviatedRelativeLocationPath import ParsedAbbreviatedRelativeLocationPath
File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/ParsedAbbreviatedRelativeLocationPath.py", line 31
as = ParsedAxisSpecifier.ParsedAxisSpecifier('descendant-or-self')
^
SyntaxError: invalid syntax
Looking it up led me to understand that this is because 'as' is a reserved name in python-2.6 and PyXML-0.8.4 tries to redefine it. However, there are no directions on how to resolve this issue.
Please advise.
PyXML is obsolete and should not be used (see here). That's why there are no updates for it. Many features that were included in it were added to Python's standard library. There are also fully-supported third-party packages for Python XML processing like lxml.
Several times I've seen mention that for asynchronous ping is good to use twisted.
I written implementation on threads (like Ping a site in Python?)
But on ~200 threads i have crush
On page http://twistedmatrix.com/trac/wiki/ProjectsUsingTwisted i find
txNetTools - Ping, traceroute, icmp, etc., implemented in Twisted, and a library for those who want to build their own network tools.
Has anyone used this library?
I tried to use it ping.py:
Traceback (most recent call last):
File "ping.py", line 23, in <module>
class Pinger(ICMP):
NameError: name 'ICMP' is not defined
if change:
class Pinger(**ICMP**):
to
class Pinger():
Traceback (most recent call last):
File "ping.py", line 54, in <module>
reactor.listenICMP(0, Pinger())
File "./txnet/reactor.py", line 21, in listenICMP
p.startListening()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/udp.py", line 102, in startListening
self._connectToProtocol()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/udp.py", line 123, in _connectToProtocol
self.protocol.makeConnection(self)
AttributeError: Pinger instance has no attribute 'makeConnection'
Maybe I'm doing something wrong or not understand?
P.S. twisted 12.0
If you are running sandbox/ping.py, then the exception you report doesn't make sense. That file has this import near the beginning:
from txnet.icmp import ICMP, Packet, ECHO_REQUEST
This defines the ICMP name. The Pinger class comes later, extending it. I can successfully run this demo program (though it fails with an unrecognized message type when handling the response on my sytem).
Perhaps you have an old version of the code, or have modified it somehow, or are running a different ping.py?