【问题标题】:Build of kivy-ios app in Xcode 11.5 failing with Python syntax errors在 Xcode 11.5 中构建 kivy-ios 应用程序失败并出现 Python 语法错误
【发布时间】:2020-11-05 04:41:48
【问题描述】:

我已经使用工具链为 iOS 构建了我的 kivy 应用程序。打开生成的 xcode 项目并开始构建过程后,我收到以下错误。

Listing '/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/stopwining.xcodeproj/xcuserdata/martinprater.xcuserdatad/xcschemes'...
/Users/martinprater/ios/stopwining-ios/YourApp/.buildozer/android/app/lib/python3.8/site-packages/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
/Users/martinprater/ios/stopwining-ios/YourApp/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stopwiningmobile/kivy/extras/highlight.py:45: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if len(sys.argv) is not 4:
/Users/martinprater/ios/stopwining-ios/YourApp/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stopwiningmobile/kivy/uix/behaviors/focus.py:463: SyntaxWarning: "is" with a literal. Did you mean "=="?
  walk_tree = 'walk' if focus_dir is 'focus_next' else 'walk_reverse'
/Users/martinprater/ios/stopwining-ios/YourApp/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stopwiningmobile/kivy/uix/behaviors/focus.py:476: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if focus_dir is 'focus_next':
/Users/martinprater/ios/stopwining-ios/YourApp/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stopwiningmobile/kivy/uix/behaviors/knspace.py:460: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if parent_knspace is not 0:
/Users/martinprater/ios/stopwining-ios/YourApp/build/hostpython3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/hostpython3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/hostpython3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/python3/arm64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/python3/arm64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/python3/arm64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/python3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/python3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/build/python3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/site-packages/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
/Users/martinprater/ios/stopwining-ios/YourApp/lib/python3.8/site-packages/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/.buildozer/android/app/lib/python3.8/site-packages/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/hostpython3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/hostpython3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/hostpython3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/python3/arm64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/python3/arm64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/python3/arm64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/python3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/python3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/build/python3/x86_64/Python-3.8.2/Lib/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/lib2to3/tests/data/py3_test_grammar.py:652: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 is 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/lib2to3/tests/data/py3_test_grammar.py:653: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/lib2to3/tests/data/py3_test_grammar.py:656: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/dist/hostpython3/lib/python3.8/site-packages/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/lib/python3.8/site-packages/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
/Users/martinprater/ios/stopwining-ios/YourApp/stopwining-ios/YourApp/stopwining-ios/YourApp/lib/python3.8/site-packages/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
  raise TypeError("%s and %s are not of the same version" (a, b))
Command PhaseScriptExecution failed with a nonzero exit code 

这似乎是 python 版本的不匹配。 直接从我的虚拟环境运行编译脚本没有任何错误:

/Users/martinprater/ios/dist/hostpython3/bin/python -m compileall -f -b "$PROJECT_DIR"/YourApp

我尝试通过 pyenv 和预构建脚本在全局范围内设置 Python 环境以强制使用 Python 3.8.2。 但是在Xcode(11.5)中好像没有生效。

我试过了:

  • 使用虚拟环境和全局安装效果一样。
  • Python 3.7 和 Python 3.8 -> 效果相同
  • 重新安装 Xcode 并重建所有配方 -> 没有变化。

热烈感谢任何帮助。 谢谢, 马丁

【问题讨论】:

    标签: python ios xcode kivy


    【解决方案1】:

    为了解决这个问题,我们必须将 == 更改为 is
    这是完整的博客https://adamj.eu/tech/2020/01/21/why-does-python-3-8-syntaxwarning-for-is-literal/

    【讨论】:

    • 首先:不!我们必须将“is”更改为“==”,将“is not”更改为“!=”。其次:许多文件位于名为“lib2to3/tests/data/”的子文件夹中。它们真的有必要吗?他们不能被排除在构建过程之外吗?
    猜你喜欢
    • 2019-04-05
    • 2020-03-30
    • 1970-01-01
    • 2020-10-06
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多