2

我重新安装了我的电脑,Shady 以前可以工作(我几乎没有掌握它是如何工作的,但它确实有效)。现在我似乎什至无法开始任何事情。

我是新手

当我尝试运行演示时,这就是我得到的。我认为它与阴暗无关,但我的设置有问题。我重新安装了蟒蛇,python 3.7.4

$ python -m Shady demo showcase

In [1]:                                                                         


Let's set up the "World" in which our Stimuli will reside.  Since we
don't know you well enough yet to know how you're arranging your
windows and screens, let's take the unusual step of making the World
a framed, draggable window.



        world = Shady.World( width=1200, height=700, top=50, frame=True )

        world.MakeCanvas( gamma=2.2 )  # you can also have this step done
                                       # automatically by including canvas=True
                                       # in the World constructor line (along
                                       # with any other physical properties
                                       # like gamma)


(press ctrl-D to run)

In [1]:   




SyntaxError                               Traceback (most recent call last)
//anaconda3/lib/python3.7/runpy.py in _run_module_as_main(mod_name, alter_argv)
    191         sys.argv[0] = mod_spec.origin
    192     return _run_code(code, main_globals, None,
--> 193                      "__main__", mod_spec)
    194 
    195 def run_module(mod_name, init_globals=None,

//anaconda3/lib/python3.7/runpy.py in _run_code(code, run_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
     83                        __package__ = pkg_name,
     84                        __spec__ = mod_spec)
---> 85     exec(code, run_globals)
     86     return run_globals
     87 

//anaconda3/lib/python3.7/site-packages/Shady/__main__.py in <module>
    264 if main in [ 'unrecognized', 'absent' ]: main = subcommands[ 'run' ]
    265 else: sys.argv.pop( 1 )
--> 266 main()

//anaconda3/lib/python3.7/site-packages/Shady/__main__.py in <lambda>()
    244 subcommands = dict(
    245         list = ListDemos,
--> 246         demo = lambda: Shady.Utilities.RunShadyScript( *sys.argv[ 1: ] ) if sys.argv[ 1: ] else ListDemos(),
    247         run = lambda: Shady.Utilities.RunShadyScript( '--console=None', *sys.argv[ 1: ] ),
    248         shell = lambda: Shady.Utilities.RunShadyScript( '--skipShadyInteractionUntilTheEnd', *sys.argv[ 1: ] ),

//anaconda3/lib/python3.7/site-packages/Shady/Utilities.py in RunShadyScript(*argv, **kwargs)
   1762                                 time.sleep( 0.010 )
   1763                 ei = user_ns.pop( '_SHADY_CONSOLE_EXCEPTION_INFO', None )
-> 1764                 if ei: reraise( *ei )
   1765         except CommandLineError as exc:
   1766                 print( exc )

//anaconda3/lib/python3.7/site-packages/Shady/Utilities.py in reraise(cls, instance, tb)
     67 import threading
     68 
---> 69 def reraise( cls, instance, tb=None ): raise ( cls() if instance is None else instance ).with_traceback( tb )
     70 try: Exception().with_traceback
     71 except: exec( 'def reraise( cls, instance, tb=None ): raise cls, instance, tb' ) # has to be wrapped in exec because this would be a syntax error in Python 3.0

//anaconda3/lib/python3.7/site-packages/Shady/Console.py in RunScript(script, on_close, user_ns, color, threaded, interactive, prefer_ipython)
    546         compiled = compile( code, script, 'exec' )
    547         einfo = []
--> 548         try: _exec( compiled, user_ns )
    549         except AbortInteraction: pass
    550         except: einfo = sys.exc_info()

//anaconda3/lib/python3.7/site-packages/Shady/Console.py in _exec(compiled, user_ns)
    481         if pause: sys.stdout.write( '\n(press %s to %s)\n' % ( 'ctrl-D' if isIPython else 'enter', 'run' if code else 'continue' ) )
    482 
--> 483 def _exec( compiled, user_ns ): exec( compiled, user_ns, user_ns )
    484 def RunScript( script, on_close=None, user_ns=None, color=True, threaded=True, interactive=False, prefer_ipython=True ):
    485         global SCRIPT_THREAD, SHELL_THREAD

/anaconda3/lib/python3.7/site-packages/Shady/examples/showcase.py in <module>
     54                 a framed, draggable window.
     55         """#:
---> 56                 world = Shady.World( width=1200, height=700, top=50, frame=True )
     57                 world.MakeCanvas( gamma=2.2 )  # you can also have this step done
     58                                                # automatically by including canvas=True

//anaconda3/lib/python3.7/site-packages/Shady/Rendering.py in __init__(self, width, height, left, top, screen, threaded, canvas, frame, fullScreenMode, visible, openglContextVersion, legacy, backend, acceleration, debugTiming, profile, syncType, logfile, reportVersions, window, **kwargs)
   1486                         if self._fatal: reraise( *self._fatal )
   1487                 elif hijacker:
-> 1488                         hijacker.WaitFor( self._Construct, **kwargs )
   1489                         hijacker.Queue( self.Run )
   1490                         while self.__state != 'running' and hijacker.running: time.sleep( 0.1 )

//anaconda3/lib/python3.7/site-packages/Shady/Console.py in WaitFor(self, func, *pargs, **kwargs)
    243                 container = self.Queue( func, *pargs, **kwargs )
    244                 while not container: time.sleep( 0.001 )
--> 245                 if len( container ) > 1: reraise( *container )
    246                 return container[ 0 ]
    247         def Run( self ):

//anaconda3/lib/python3.7/site-packages/Shady/Console.py in reraise(cls, instance, tb)
     44 if sys.version < '3': bytes = str
     45 else: unicode = str; basestring = ( unicode, bytes )
---> 46 def reraise( cls, instance, tb=None ): raise ( cls() if instance is None else instance ).with_traceback( tb )
     47 try: Exception().with_traceback
     48 except: exec( 'def reraise( cls, instance, tb=None ): raise cls, instance, tb' ) # has to be wrapped in exec because this would be a syntax error in Python 3.0

//anaconda3/lib/python3.7/site-packages/Shady/Console.py in Run(self)
    257                                 else:
    258                                         if func is self.__stop: break
--> 259                                         try: container.append( func( *pargs, **kwargs ) )
    260                                         except: container.extend( sys.exc_info() )
    261                         except KeyboardInterrupt:

//anaconda3/lib/python3.7/site-packages/Shady/Rendering.py in _Construct(self, width, height, window, left, top, screen, canvas, frame, fullScreenMode, visible, openglContextVersion, legacy, debugTiming, profile, syncType, reportVersions, **kwargs)
   1531 
   1532                         if hasattr( window, 'TabulaRasa' ): window.TabulaRasa()
-> 1533                         window = window( **window_kwargs )
   1534                 self.window = window
   1535                 self.window.excepthook = ExceptionHook

//anaconda3/lib/python3.7/site-packages/Shady/ShaDyLibWindowing.py in __init__(self, width, height, left, top, screen, frame, fullScreenMode, visible, openglContextVersion, legacy, glslDirectory, substitutions)
     90                 try:
     91                         adjusted = dict( left=left, top=top, width=width, height=height )
---> 92                         pixelScaling = DPI.CheckRetinaScaling( screen=screen, raiseException=True, adjust=adjusted )
     93                         #left, top, width, height = [ adjusted[ field ] for field in 'left top width height'.split() ]  # TODO: would like to uncomment this so that you get the resolution you ask for, but then the coordinates would be inconsistent with Shady.Screens() outputs...
     94                 except OSError as err:

//anaconda3/lib/python3.7/site-packages/Shady/DPI.py in CheckRetinaScaling(screen, raiseException, adjust)
    171         out, err = [ x if x is str else x.decode( 'ascii', errors='ignore' ) for x in sp.communicate( applescript.encode( 'utf-8' ) ) ]
    172         if err or sp.returncode: raise OSError( 'Applescript returned error code ' + str( sp.returncode ) + ( ': ' if err else '' ) + err  )
--> 173         screenInfo = ast.literal_eval( out )
    174         if 'error' in screenInfo: raise ValueError( screenInfo[ 'error' ] )
    175 

//anaconda3/lib/python3.7/ast.py in literal_eval(node_or_string)
     44     """
     45     if isinstance(node_or_string, str):
---> 46         node_or_string = parse(node_or_string, mode='eval')
     47     if isinstance(node_or_string, Expression):
     48         node_or_string = node_or_string.body

//anaconda3/lib/python3.7/ast.py in parse(source, filename, mode)
     33     Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
     34     """
---> 35     return compile(source, filename, mode, PyCF_ONLY_AST)
     36 
     37 

SyntaxError: invalid syntax (<unknown>, line 1)

谢谢您的帮助!

4

1 回答 1

1

这几乎肯定不是你的错。相反,看起来 Shady 未能解释您的操作系统传递有关系统屏幕分辨率的信息(当通过 AppleScript 查询时)的某种新方式。为什么您的 Mac 以一种新的、意想不到的方式传递这些信息?这是不可能的,因为实际的 AppleScript 输出没有被打印出来。如果您已更新到之前从未测试过 Shady 的新版本的 macOS,则可能会发生这种情况。目前它已经在 10.14(Mojave)上进行了测试,但没有在 10.15(Catalina 预览版)上进行测试——您提到的“重新安装”是否需要升级到 10.15?

这最好被视为一个错误,所以从这里开始的地方是https://bitbucket.org/snapproject/shady-gitrepo/issues 。您可以使用“创建问题”按钮在那里重新提交您的报告吗?如那里的介绍文本所述Shady.ReportVersions(),除了上面包含的错误回溯之外,将输出粘贴到错误报告中会很有价值。这将显示 macOS 版本等。

于 2019-08-12T19:03:01.857 回答