使用 pyinstaller 生成 exe 文件的错误 - typeerror: expected str, bytes or os.PathLike object, not NoneType [英] An error for generating an exe file using pyinstaller - typeerror: expected str, bytes or os.PathLike object, not NoneType
问题描述
我正在尝试使用 pysinstaller
和 Python 3.7.2 从 .py
文件构建一个 .exe
文件.
I am trying to build an .exe
file from .py
file using pysinstaller
and Python 3.7.2.
它适用于 Python 3.6;然后我重新安装了最新版本的 Python(3.7.2)并尝试生成一个 exe 文件,但 pyinstaller barfs.
It worked with Python 3.6; then I re-installed the last version of Python (3.7.2) and tried to generate an exe file, but pyinstaller barfs.
下面是我得到的错误报告.
Below is the error report I get.
(venv) C:\Users\user\Desktop\untitled1>pyinstaller test.py
53 INFO: PyInstaller: 3.4
53 INFO: Python: 3.7.2
54 INFO: Platform: Windows-10-10.0.17134-SP0
58 INFO: wrote C:\Users\user\Desktop\untitled1\test.spec
60 INFO: UPX is not available.
61 INFO: Extending PYTHONPATH with paths
['C:\\Users\\user\\Desktop\\untitled1', 'C:\\Users\\user\\Desktop\\untitled1']
61 INFO: checking Analysis
187 INFO: checking PYZ
236 INFO: checking PKG
237 INFO: Building PKG because PKG-00.toc is non existent
238 INFO: Building PKG (CArchive) PKG-00.pkg
Traceback (most recent call last):
File "C:\Users\user\Desktop\untitled1\venv\Scripts\pyinstaller-script.py", line 11, in <module>
load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')()
File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\user\Desktop\untitled1\venv\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\user\Desktop\untitled1\venv\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\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 424, in __init__
strip_binaries=self.strip, upx_binaries=self.upx,
File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 196, in __init__
self.__postinit__()
File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 273, in assemble
pylib_name = os.path.basename(bindepend.get_python_library_path())
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 214, in basename
return split(p)[1]
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 183, in split
p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType
可能是什么问题?
推荐答案
我找到了以下解决方案:replace bindepend.py
from <myProject_path>\venv\Lib\site-packages\PyInstaller\depend
与 Loran425 在 github 上提供的文件 这里
I found the following solution: replace bindepend.py
from <myProject_path>\venv\Lib\site-packages\PyInstaller\depend
with the file provided by Loran425 on github here
这篇关于使用 pyinstaller 生成 exe 文件的错误 - typeerror: expected str, bytes or os.PathLike object, not NoneType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!