Im using PyMel to write up some tools, but as of yesterday my PyMel modules won't source, due to an error that I get during import:
import pymel.core as pm
# pymel.core : Updating pymel with pre-loaded plugins: OpenEXRLoader, DirectConnect, mayaHIK, ikSpringSolver, Mayatomr, decomposeMatrix, tiffFloatReader, VectorRender, studioImport, mayaCharacterization, rotateHelper, MayaCryExport22012-x64, Substance, MayaMuscle, fbxmaya, ik2Bsolver #
# pop from empty list
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# File "C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages\pymel-1.0.0-py2.6.egg\pymel\core\__init__.py", line 250, in <module>
# _installCallbacks()
# File "C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages\pymel-1.0.0-py2.6.egg\pymel\core\__init__.py", line 248, in _installCallbacks
# _pluginLoaded( plugin )
# File "C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages\pymel-1.0.0-py2.6.egg\pymel\core\__init__.py", line 79, in _pluginLoaded
# _factories.cmdlist[funcName] = _factories.cmdcache.getCmdInfoBasic( funcName )
# File "C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages\pymel-1.0.0-py2.6.egg\pymel\internal\cmdcache.py", line 212, in getCmdInfoBasic
# synopsis = lines.pop(0)
# IndexError: pop from empty list #
any ideas on how to fix this? I downloaded the newest version of PyMel, checked the install guide if I left anything out (i used method 2), but i still have no idea what the problem is.
Thx,
Nils
Alright, so after trying to re-install most of my programs I simply fixed the cdmcashe.py from where the error comes from - I ddnt originally want to do this because I wasnt sure what I might break, but after over 2 weeks of trying things out I just went for broke:
If anyone else has this problem, all u need to do is open your cmdcache.py and add an if test to line 212
if lines:
That'll just fix it.
yeah. simple as that. Imagine the head->desking session I had after doing that.
Related
I am trying to use PyAutoGui's locateCenterOnScreen() function in PyCharm. However, it always throws an error even though it works in VS Code. I am running on an M1 Macbook Air w/ macOS Monterey. I have PyAutoGui version 0.9.53 installed. Does anyone know why it does this?
Traceback (most recent call last):
File "/Users/username/Desktop/Files/Programming/Projects/Auto Mining Tool/main.py", line 3, in <module>
x, y = pyautogui.locateCenterOnScreen('image.png')
File "/Users/username/Library/Python/3.8/lib/python/site-packages/pyautogui/__init__.py", line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File "/Users/username/Library/Python/3.8/lib/python/site-packages/pyautogui/__init__.py", line 207, in locateCenterOnScreen
return pyscreeze.locateCenterOnScreen(*args, **kwargs)
File "/Users/andrewwalker/Library/Python/3.8/lib/python/site-packages/pyscreeze/__init__.py", line 413, in locateCenterOnScreen
coords = locateOnScreen(image, **kwargs)
File "/Users/andrewwalker/Library/Python/3.8/lib/python/site-packages/pyscreeze/__init__.py", line 372, in locateOnScreen
screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
File "/Users/andrewwalker/Library/Python/3.8/lib/python/site-packages/pyscreeze/__init__.py", line 477, in _screenshot_osx
im = Image.open(tmpFilename)
NameError: name 'Image' is not defined
I can tell you why, but I'm not smart enough to know how to fix it.
The reason seems to stem from updates. I just ran into this problem today myself, I typically build projects and then never update modules etc.
Did you update modules prior to this happening?
It seems they've changed function names, and other modules that were built by other people either were not updated, or have import errors, resulting in pyscreeze and pyautogui not playing nice together.
I'm on an osx machine. Matplotlib was working fine a few days back, but today when i wanted to use it it just won't import. There are a bunch of lines and at the bottom it gives me a type error goes on about a copy function needing another variable. I've tried reinstalling it and still wont budge. any thoughts? I'm still fairly new to this so i have no idea whats going on.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/__init__.py", line 138, in <module>
from . import cbook, rcsetup
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/rcsetup.py", line 24, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/fontconfig_pattern.py", line 18, in <module>
from pyparsing import (Literal, ZeroOrMore, Optional, Regex, StringEnd,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 5658, in <module>
_reBracketExpr = Literal("[") + Optional("^").setResultsName("negate") + Group(OneOrMore(_charRange | _singleChar)).setResultsName("body") + "]"
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 1480, in setResultsName
return self._setResultsName(name, listAllMatches)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 1483, in _setResultsName
newself = self.copy()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyparsing.py", line 1437, in copy
cpy = copy.copy(self)
TypeError: copy() missing 2 required positional arguments: 'E' and 'X'
Not sure if it's related, but when I migrated to OSX I had problems with matplotlib which were solved by changing the backend:
import matplotlib
matplotlib.use("MacOSX")
Thanks for the response, it turns out matplotlib didn't like the directory I was in, which is odd. Just changing where i was trying to run it from worked.
I'm trying to get started using speech recognition in python. First I tried PySpeech (https://code.google.com/p/pyspeech/) using this code:
def listen():
while 1:
said = speech.input()
print said
if said == "off":
break
and got the following traceback:
Traceback (most recent call last):
File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 59, in <module> useful.listen()
File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 48, in listen
said = speech.input()
File "C:\Python27\lib\site-packages\speech.py", line 162, in input
listener = listenforanything(response)
File "C:\Python27\lib\site-packages\speech.py", line 193, in listenforanything
return _startlistening(None, callback)
File "C:\Python27\lib\site-packages\speech.py", line 223, in _startlistening
grammar = context.CreateGrammar()
File "C:\Users\REDACTED\AppData\Local\Temp\gen_py\2.7\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 2298, in CreateGrammar
ret = self._oleobj_.InvokeTypes(14, LCID, 1, (9, 0), ((12, 49),),GrammarId
AttributeError: 'module' object has no attribute 'VARIANT'
Then I tried dragonfly per the suggestion at the top of the GoogleCode page for PySpeech using the following example code commonly found on dragonfly docs:
from dragonfly.all import Grammar, CompoundRule
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
spec = "do something computer" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print "Voice command spoken."
# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar") # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule()) # Add the command rule to the grammar.
grammar.load() # Load the grammar.
and got this very similar traceback:
Traceback (most recent call last):
File "C:/Users/REDACTED/Documents/Python Projects/listen.py", line 14, in <module>
grammar.load() # Load the grammar.
File "C:\Python27\lib\site-packages\dragonfly\grammar\grammar_base.py", line 302, in load
self._engine.load_grammar(self)
File "C:\Python27\lib\site-packages\dragonfly\engines\engine_sapi5.py", line 79, in load_grammar
handle = self._compiler.compile_grammar(grammar, context)
File "C:\Python27\lib\site-packages\dragonfly\engines\compiler_sapi5.py", line 68, in compile_grammar
grammar_handle = context.CreateGrammar()
File "C:\Users\REDACTED\AppData\Local\Temp\gen_py\2.7\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 2298, in CreateGrammar
ret = self._oleobj_.InvokeTypes(14, LCID, 1, (9, 0), ((12, 49),),GrammarId
AttributeError: 'module' object has no attribute 'VARIANT'
Both modules were installed using PIP and run using python 2.7 interpreter. It seems like a python version issue to me given that the same error is thrown for two different modules implementing the same thing but I'm pretty stuck on how to proceed.
Any help is greatly appreciated and I'm happy to provide more code/info as its requested. Thanks!
EDIT 1: For anyone experiencing a similar problem who happens to stumble across this post, try https://pypi.python.org/pypi/SpeechRecognition/ as an alternative on py2.7. If it runs without error but behaves inconsistently or infinite loops, try modifying the init method of the recognizer class in init.py around line 100. The energy threshold required some tinkering for me (100->300) which is likely due to the specifics of your mic setup. I also increased my quiet duration (0.5->0.7) because it would cut me off sometimes. After these changes it works fairly well for me, returning very accurate text of the input speech in ~2 seconds after capture ends.
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.
Using OS X 10.6.8, libxml 2-2.7.8, libxslt-1.1.26, and python 2.6, I'm trying to run the tumblrRestore.py script linked here:
https://github.com/hughsaunders/Tumblr-Restore/blob/master/tumblrRestore.py
It ran successfully and restored 76 posts before crashing.
However on second run I got an ExpatError: no element found, and have not been able to run it successfully since - it always produces this same error now. Error text:
Tumblr Restore
Traceback (most recent call last):
File "tumblrRestore.py", line 264, in <module>
cli.start()
File "tumblrRestore.py", line 232, in start
bp.parse()
File "tumblrRestore.py", line 51, in parse
postelement=ElementTree.fromstring(xml_string)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/etree/ElementTree.py", line 964, in XM
return parser.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/etree/ElementTree.py", line 1254, in close
self._parser.Parse("", 1) # end of data
xml.parsers.expat.ExpatError: no element found: line 1, column 0
I'm wondering whether I have the wrong or competing or outdated versions of python or lxml, though that still doesn't explain why the script ran successfully once.
Complete newbie, any advice appreciated.
Check your extract_xml_string method of BackupParser class. It definitely returns empty string, because your begin_re regular expresssion doesn't match xml header.
Try the next one:
begin_re = re.compile("<\? xml .*\?>")