kvarenzn / phisap

[deprecated] [for android] Semi-automatic player for the rhythm game "Phigros"
174 stars 38 forks source link

Unsupported operand type(s) for |: 'type' and 'NoneType' #25

Closed Hydroge closed 2 years ago

Hydroge commented 2 years ago

The Error

C:\Users\so\Desktop\phisap-main>main.py
Traceback (most recent call last):
  File "C:\Users\so\Desktop\phisap-main\main.py", line 9, in <module>
    from catalog import Catalog
  File "C:\Users\so\Desktop\phisap-main\catalog.py", line 5, in <module>
    from binary_reader import BinaryReader
  File "C:\Users\so\Desktop\phisap-main\binary_reader.py", line 7, in <module>
    class BinaryReader:
  File "C:\Users\so\Desktop\phisap-main\binary_reader.py", line 23, in BinaryReader
    _header_backup: str | None
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

I have changed nothing in the source code.

Python version

Python 3.10.0 | packaged by conda-forge | (default, Nov 10 2021, 13:20:59) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Adb version

Android Debug Bridge version 1.0.41
Version 33.0.1-8253317
Installed as C:\Users\so\Desktop\phisap-main\adb.exe

Scrcpy

I have downloaded scrcpy-server-v1.22, which is about 40 KB, and move it to the root directory.

The Game

Phigros 2.0.0 with "Introduction" cleared.

The Device

HUAWEI Mate 30 Pro

kvarenzn commented 2 years ago

你好,虽然很抱歉,但我还是想确认一下:你确定是在用你贴出来的这个版本的Python(Python 3.10.0 | packaged by conda-forge)运行的phisap吗? 因为你遇到的这个问题与adbscrcpyphigros的版本无关,而只有可能与Python解释器的版本有关(在某个版本以前python不支持str | None这种写法,只能用Optional[str]代替,造成了语法上的不兼容),而且Python在Windows系统下经常会有装多个版本但默认的解释器是某个版本的情况。 请按照如下方式确认: 打开main.py,在文件的最开始加入下面三句话:

import sys
print(sys.version)
sys.exit()

上述三行代码的作用是打印正在执行phisap的解释器的版本信息。请保存文件后重新在命令行运行main.py,并确认打印出的这个版本信息是不是3.10.0

Hydroge commented 2 years ago

显示的是3.8.x,果然是版本的问题。我的想法是使用conda安装3.10的环境,再通过3.10来运行本程序。但似乎一跑起来的话还是3.8,或许我该考虑一下是不是anaconda的设置出现问题。

无论如何,十分感谢!

kvarenzn commented 2 years ago

在windows开始菜单有个anaconda的命令行启动器。运行之后可以得到配置好python 3.10的命令行环境。在那个命令行里运行phisap应该可以。