升级到2023.3.3社区版时打包操作失败

问题描述 投票:0回答:1

升级到后,File/Settings/myproject/Python Interpreter 永远不会列出包。屏幕底部的线条显示 ,而通知显示

详细打包操作界面如下:

Packaging Operation Failed

Executed command:
C:\Users\l...ya\Pycharm\Projection\Scripts\python.exe C:/Program Files/JetBrains/PyCharm Community Edition 2023.2.3/plugins/python-ce/helpers/packaging_tool.py list

Error occured:
TypeError: sequence item 0: expected str instance, NoneType found

Command output:
astroid 3.0.1   C:\Users\l...a\Pycharm\Projection\lib\site-packages typing-extensions >=4.0.0 ; python_version < "3.11"
colorama    0.4.6   C:\Users\l...a\Pycharm\Projection\lib\site-packages 
contourpy   1.2.0   C:\Users\l...a\Pycharm\Projection\lib\site-packages numpy<2.0,>=1.20:furo; extra == "docs":sphinx>=7.2; extra == "docs":sphinx-copybutton; extra == "docs":bokeh; extra == "bokeh":selenium; extra == "bokeh":contourpy[bokeh,docs]; extra == "mypy":docutils-stubs; extra == "mypy":mypy==1.6.1; extra == "mypy":types-Pillow; extra == "mypy":contourpy[test-no-images]; extra == "test":matplotlib; extra == "test":Pillow; extra == "test":pytest; extra == "test-no-images":pytest-cov; extra == "test-no-images":pytest-xdist; extra == "test-no-images":wurlitzer; extra == "test-no-images"
cycler  0.12.1  C:\Users\l...a\Pycharm\Projection\lib\site-packages ipython ; extra == 'docs':matplotlib ; extra == 'docs':numpydoc ; extra == 'docs':sphinx ; extra == 'docs':pytest ; extra == 'tests':pytest-cov ; extra == 'tests':pytest-xdist ; extra == 'tests'
dill    0.3.7   C:\Users\l...a\Pycharm\Projection\lib\site-packages objgraph (>=1.7.2) ; extra == 'graph'
et-xmlfile  1.1.0   C:\Users\l...a\Pycharm\Projection\lib\site-packages 
fonttools   4.46.0  C:\Users\l...a\Pycharm\Projection\lib\site-packages fs <3,>=2.2.0 ; extra == 'all':lxml <5,>=4.0 ; extra == 'all':zopfli >=0.1.4 ; extra == 'all':lz4 >=1.7.4.2 ; extra == 'all':matplotlib ; extra == 'all':sympy ; extra == 'all':skia-pathops >=0.5.0 ; extra == 'all':uharfbuzz >=0.23.0 ; extra == 'all':brotlicffi >=0.8.0 ; (platform_python_implementation != "CPython") and extra == 'all':scipy ; (platform_python_implementation != "PyPy") and extra == 'all':brotli >=1.0.1 ; (platform_python_implementation == "CPython") and extra == 'all':munkres ; (platform_python_implementation == "PyPy") and extra == 'all':unicodedata2 >=15.1.0 ; (python_version <= "3.12") and extra == 'all':xattr ; (sys_platform == "darwin") and extra == 'all':lz4 >=1.7.4.2 ; extra == 'graphite':scipy ; (platform_python_implementation != "PyPy") and extra == 'interpolatable':munkres ; (platform_python_implementation == "PyPy") and extra == 'interpolatable':lxml <5,>=4.0 ; extra == 'lxml':skia-pathops >=0.5.0 ; extra == 'pathops':matplotlib ; extra == 'plot':uharfbuzz >=0.23.0 ; extra == 'repacker':sympy ; extra == 'symfont':xattr ; (sys_platform == "darwin") and extra == 'type1':fs <3,>=2.2.0 ; extra == 'ufo':unicodedata2 >=15.1.0 ; (python_version <= "3.12") and extra == 'unicode':zopfli >=0.1.4 ; extra == 'woff':brotlicffi >=0.8.0 ; (platform_python_implementation != "CPython") and extra == 'woff':brotli >=1.0.1 ; (platform_python_implementation == "CPython") and extra == 'woff'
future  0.18.3  C:\Users\l...a\Pycharm\Projection\lib\site-packages 
isort   6.0.0b2 C:\Users\l...a\Pycharm\Projection\lib\site-packages colorama (>=0.4.3,<0.5.0) ; extra == "colors":pip-api ; extra == "requirements-deprecated-finder":pipreqs ; extra == "pipfile-deprecated-finder" or extra == "requirements-deprecated-finder":requirementslib ; extra == "pipfile-deprecated-finder":setuptools ; extra == "plugins"
kiwisolver  1.4.5   C:\Users\l...a\Pycharm\Projection\lib\site-packages typing-extensions ; python_version < "3.8"
matplotlib  3.8.2   C:\Users\l...a\Pycharm\Projection\lib\site-packages contourpy >=1.0.1:cycler >=0.10:fonttools >=4.22.0:kiwisolver >=1.3.1:numpy <2,>=1.21:packaging >=20.0:pillow >=8:pyparsing >=2.3.1:python-dateutil >=2.7:importlib-resources >=3.2.0 ; python_version<"3.10"
mccabe  0.7.0   C:\Users\l...a\Pycharm\Projection\lib\site-packages 
numexpr 2.8.7   C:\Users\l...a\Pycharm\Projection\lib\site-packages numpy >=1.13.3
numpy   1.26.2  C:\Users\l...a\Pycharm\Projection\lib\site-packages 
openpyxl    3.2.0b1 C:\Users\l...a\Pycharm\Projection\lib\site-packages et-xmlfile
packaging   23.2    C:\Users\l...a\Pycharm\Projection\lib\site-packages 

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.2.3\plugins\python-ce\helpers\packaging_tool.py", line 118, in main
    do_list()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.2.3\plugins\python-ce\helpers\packaging_tool.py", line 64, in do_list
    sys.stdout.write('\t'.join([pkg.name, pkg.version, str(pkg._path.parent), requires])+chr(10))
TypeError: sequence item 0: expected str instance, NoneType found

我只是不知道还能尝试什么。

感谢您的帮助。

pycharm
1个回答
0
投票

代码中的错误是由于您尝试使用 ' '.join(...) 连接的列表中的元素之一是 NoneType 类型。具体来说,似乎 pkg.version 或 require 在一次迭代中为 None。

要解决此问题,您应该在尝试将它们连接到字符串之前检查 None 值。您可以使用 str() 函数将它们安全地转换为字符串。以下是如何修改代码的示例:

sys.stdout.write('\t'.join([str(pkg.name), str(pkg.version), str(pkg._path.parent), str(requires)]) + chr(10))

通过对每个元素使用 str(),您可以确保即使其中任何一个元素为 None,它也会被转换为字符串表示形式,从而防止出现 TypeError。

© www.soinside.com 2019 - 2024. All rights reserved.