So I have found an error in a module I am using (which one is unimportant, but if you must know it's geopy.distance)
So I know what I have to do to fix the code, but when I open the .py file and edit it, it acts as if it was not edited!
Here is the error traceback before edited:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/geopy-0.95.1-py2.7.egg/geopy/distance.py", line 37, in __init__
kilometers += self.measure(a, b)
File "/Library/Python/2.7/site-packages/geopy-0.95.1-py2.7.egg/geopy/distance.py", line 72, in measure
raise NotImplementedError
NotImplementedError
Here is the error traceback after I edit the file:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/geopy-0.95.1-py2.7.egg/geopy/distance.py", line 37, in __init__
kilometers += self.measure(a, b)
File "/Library/Python/2.7/site-packages/geopy-0.95.1-py2.7.egg/geopy/distance.py", line 72, in measure
a, b = Point(a), Point(b)
NotImplementedError
as you can see, I changed it so it would not raise NotImplementedError, but it is still raising it! How is this possible?
Looks like you've edited a .py file, but the user process doesn't have permission to overwrite the .pyc file. The NotImplementedError is still on line 72 according to the .pyc file, but it's displaying the current line 72 from the .py file
Aside: Looks like Distance is an abstract class. You're not supposed to instantiate directly, but one of the subclasses of it. Eg GreatCircleDistance or VincentyDistance
Also notice the last two lines in the file
# Set the default distance formula to the most generally accurate.
distance = VincentyDistance
Related
I am creating a nbt file whose root has two tags:
DataVersion. It must be a tag_Int.
size. You must set a tag_List of 3 tag_ints.
I did a few tests and determined that an error occurs when I try to pass a tag_List to the file.
This is my code:
import nbtlib as nbt
class Structure(nbt.File):
def __init__(Self, data_version, size):
#super().__init__({"DataVersion":nbt.Int(data_version), "size":nbt.List(map(nbt.Int, size))})
super().__init__({"DataVersion":nbt.Int(data_version), "size":nbt.List(map(nbt.Int, size))})
structure = Structure(data_version=1952, size=(0, 0, 0))
structure.save("prueba.nbt")
This is the error:
Traceback (most recent call last):
File "D:\studios dante 2\MODULES\Games\structurenbt\module.py", line 10, in <module>
structure.save("prueba.nbt")
File "C:\Python38-32\lib\site-packages\nbtlib\nbt.py", line 132, in save
self.write(buff, byteorder or self.byteorder)
File "C:\Python38-32\lib\site-packages\nbtlib\tag.py", line 420, in write
tag.write(buff, byteorder)
File "C:\Python38-32\lib\site-packages\nbtlib\tag.py", line 365, in write
write_numeric(BYTE, self.subtype.tag_id, buff, byteorder)
File "C:\Python38-32\lib\site-packages\nbtlib\tag.py", line 84, in write_numeric
buff.write(fmt[byteorder].pack(value))
struct.error: required argument is not an integer
Can someone help me to fix the problem? I use python 3.8
I already fixed it, turns out I had the nbtlib out of date. I updated it and it works!
I am trying to set up the ChirpSDK, but every time I configure and run the code, I get this error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
chirp = ChirpSDK()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 395, in __init__
self.read_chirprc(block)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 501, in read_chirprc
raise IOError('Could not find a ~/.chirprc file')
OSError: Could not find a ~/.chirprc file
Exception ignored in: <function ChirpSDK.__del__ at 0x10fa31af0>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 422, in __del__
self.close()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 470, in close
if self._sdk:
AttributeError: 'ChirpSDK' object has no attribute '_sdk'
I realize that the error is saying that my .chirprc file is not being recognized, but I have no idea how to remedy this. I created a .chirprc file in my /Users/username/ path, and named it c.chirprc (as the Chirp getting started article suggests), but I am still getting this error. Is there another part that I am missing? Am I reading the instructions wrong?
Thanks
The Chirp configuration file should be placed at /Users/<username>/.chirprc on macOS.
If you run ls -l ~/.chirprc in the terminal, do you get any results? If it displays no such file or directory then you have not created the file correctly.
So on my game I'm making, I'm trying to load the data files needed for the game, and when I load the file with pickle (The file has been loaded, I've double-checked that.) I get this error:
Traceback (most recent call last):
File "/Users/user/Downloads/Deeper-master/Deeper.py", line 257, in <module>
tutorialData = pickle.load(tutorialFile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1384, in load
return Unpickler(file).load()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 864, in load
dispatch[key](self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1075, in load_inst
klass = self.find_class(module, name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1130, in find_class
__import__(module)
ImportError: No module named __main__
I saw a question like this on Stack Overflow, but it's a little different than my situation, so sorry if this is a duplicate, I'm just trying to figure it out.
You can find my code here. The main script is Deeper.py, just to save time.
If you notice in your repo, you have a Deeper.pyc and Deeper.py. If I run Deeper.py, it raises the same exception as yours. If I run Deeper.pyc, it raises another exception:
Traceback (most recent call last):
File "Deeper.py", line 7, in <module>
ToolbarTile = pygame.image.load("ToolbarTile.png")
pygame.error: Couldn't open Toolbar Tile.png
So, the code (bytecode, some previous version) references ToolbarTile.png, but the exception is about Toolbar Tile.png (with a space). So I changed the file name to account for that.
Now it raises:
Traceback (most recent call last):
File "Deeper.py", line 766, in <module>
else:
File "Deeper.py", line 394, in __init__
def displayCraft(self):
pygame.error: Couldn't open options.png
There's an Options.png in your files, but it looks for options.png (lower case) (even your new code in Deeper.py looks for that). So I changed that.
Now it works, albeit with Deeper.pyc so that must be why you thought:
(The file has been loaded, I've double-checked that.)
Maybe delete the Deeper.pyc and do a git-bisect to see when the bug was introduced (ps: check your toolbar.dat, does it seem okay to you? Also check the way you're using pickle.load. Maybe you should use rb instead of r?)
I can't seem to be able to execute mon Main.py because it's giving me this error:
Traceback (most recent call last):
File "main.py", line 383, in <module>
gamebase = GameBase()
File "main.py", line 278, in __init__
DGG.setDefaultRolloverSound(self.sounds['GUI_rollover'])
KeyError: 'GUI_rollover'
:TaskManager: TaskManager.destroy()
(for sure, it's sound related... and dict related, but i cant seem to figure out where the problem is)
The part where the error occur is right here:
exts = ('mp3','wav','ogg')
for x in (3,3.5,5,0):
for ext in exts:
for s in ToonGlobber.glob("phase_"+str(x)+"/audio/sfx/GUI_*."+ext,"phase_"+str(x)+"/audio/sfx"):
sf = s.split('/')[-1].split('.')[0]
self.sounds[sf] = loader.loadSfx(s)
DGG.setDefaultRolloverSound(self.sounds['GUI_rollover'])
DGG.setDefaultClickSound(self.sounds['GUI_click'])
self.pickerNode = CollisionNode('mouseRay')
self.pickerNP = camera.attachNewNode(self.pickerNode)
self.pickerNode.setIntoCollideMask(BitMask32.allOff())
self.pickerNode.setFromCollideMask(BitMask32(16))
self.pickerRay = CollisionRay()
self.pickerNode.addSolid(self.pickerRay)
What's causing this? What can be done to fix it?
It cannot find the named sound files, presumably because the phase MF is not properly mounted or does not contain the given GUI sounds.
I'm trying to open a music track and add it to a queue for a player in Pyglet.
def QueueAudio(self):
self.musicpath=filedialog.askopenfilename()
print(self.musicpath)
Player.queue(pyglet.resource.media(r"self.musicpath"))
The musicpath variable works fine as the print statement prints the filename. The error comes when the player tries to queue the track. Error below.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\pyglet\resource.py", line 605, in media
location = self._index[name]
KeyError: 'self.musicpath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Rob\Google Drive\Coursework\Part 2\music player tests\test5.py", line 99, in QueueAudio
self.playerpath=pyglet.resource.media(r"self.musicpath")
File "C:\Python33\lib\site-packages\pyglet\resource.py", line 615, in media
raise ResourceNotFoundException(name)
pyglet.resource.ResourceNotFoundException: Resource "self.musicpath" was not found on the path. Ensure that the filename has the correct captialisation.
Does anyone know why this is, and what may fix it?
This line looks to be the culprit:
self.playerpath=pyglet.resource.media(r"self.musicpath")
You are passing a string "self.musicpath" to a function, when you should be passing in the contents of a variable named self.musicpath. You need to call it like this:
self.playerpath = pyglet.resource.media(self.musicpath)