我不知道为什么当我想转换py到exe pyinstaller是不工作的

2024-07-02 12:34:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用:pyinstaller主.py你知道吗

Traceback (most recent call last):
  File "C:\Users\koksem1234\PycharmProjects\untitled\Scripts\pyinstaller-script.py", line 11, in <module>
    load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')()
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
    exec(text, spec_namespace)
  File "<string>", line 29, in <module>
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\building\api.py", line 424, in __init__
    strip_binaries=self.strip, upx_binaries=self.upx,
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\building\api.py", line 196, in __init__
    self.__postinit__()
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\Users\koksem1234\PycharmProjects\untitled\lib\site-packages\PyInstaller\building\api.py", line 273, in assemble
    pylib_name = os.path.basename(bindepend.get_python_library_path())
  File "C:\Users\koksem1234\AppData\Local\Programs\Python\Python37-32\lib\ntpath.py", line 214, in basename
    return split(p)[1]
  File "C:\Users\koksem1234\AppData\Local\Programs\Python\Python37-32\lib\ntpath.py", line 183, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Tags: inpybuildmainlibpackageslinesite
1条回答
网友
1楼 · 发布于 2024-07-02 12:34:37

你好像路过操作系统路径()某个地方的空变量或“无”。你知道吗

如果您传递os.fspath()一个字符串,它将原封不动地返回。你知道吗

否则__fspath__()被调用,只要它是字符串或字节对象,它的值就被返回。在所有其他情况下,都会引发TypeError。。你知道吗

>>> os.fspath("C:/USERS/")
'C:/USERS/'

>>> os.fspath(10)  #won't take INT
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected str, bytes or os.PathLike object, not int

>>> os.fspath(None)  #nor will it take 'None'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected str, bytes or os.PathLike object, not NoneType

相关问题 更多 >