The following error occurs when pyinstaller is packaged. It is obviously caused by the path being escaped or historical migration.
Error path:OSError: [WinError 123] The file name, directory name, or volume label syntax is incorrect. : D:\t_job\x07naconda3_20201121\Lib\site-packages’
Installation path:File “D:\11_job\anaconda3_20201121\
(base) H:\Data Collation-222\pyMyproject\001 Module Verification\pyinstall Verification>pyinstaller -c -F create_file.py 7043 INFO: PyInstaller: 6.1.0 7044 INFO: Python: 3.8.5 (conda) 7045 INFO: Platform: Windows-7-6.1.7601-SP1 7049 INFO: wrote H:\data compilation-222\pyMyproject\001 module verification\pyinstall verification\create_file.spec my yiyyyyyyyy H:\Data Collation-222\pyMyproject\001 Module Verification\pyinstall Verification\create_file.spec H:\Data Collation-222\pyMyproject\001 Module Verification\pyinstall Verification\dist H:\Data Collation-222\pyMyproject\001 Module Verification Certification\pyinstall verification\build False 7077 INFO: Extending PYTHONPATH with paths ['H:\Data Compilation-222'] 8230 INFO: checking analysis 8231 INFO: Building Analysis because Analysis-00.toc is non existent 8232 INFO: Initializing module dependency graph... 8233 INFO: Caching module graph hooks... 8304 INFO: Analyzing base_library.zip ... 24462 INFO: Loading module hook 'hook-heapq.py' from 'D:\11_job\anaconda3_20201121\lib\\site-packages\PyInstaller\\ \hooks'... 25148 INFO: Loading module hook 'hook-encodings.py' from 'D:\11_job\anaconda3_20201121\lib\\site-packages\PyInstaller\\ \hooks'... 36409 INFO: Loading module hook 'hook-pickle.py' from 'D:\11_job\anaconda3_20201121\lib\\site-packages\PyInstaller\\ \hooks'... 38155 INFO: Caching module dependency graph... 38587 INFO: Running Analysis Analysis-00.toc 38587 INFO: Looking for Python shared library... 38621 INFO: Using Python shared library: D:\11_job\anaconda3_20201121\python38.dll 38638 INFO: Analyzing H:\Data Collation-222\pyMyproject\001 Module Verification\pyinstall Verification\create_file.py 38643 INFO: Processing module hooks... 38667 INFO: Looking for ctypes DLLs 38687 INFO: Analyzing run-time hooks ... 38699 INFO: Looking for dynamic libraries 39017 INFO: Extra DLL search directories (AddDllDirectory): [] 39017 INFO: Extra DLL search directories (PATH): [] my orig_paths::: ['D:\11_job\anaconda3_20201121', 'D:\11_job\\anaconda3_20201121\lib\site-packages\ ', 'D:\t_job\x07naconda3_20201121\Lib\site-packages'] Traceback (most recent call last): File "D:\11_job\anaconda3_20201121\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\11_job\anaconda3_20201121\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\11_job\anaconda3_20201121\Scripts\pyinstaller.exe\__main__.py", line 7, in <module> File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\__main__.py", line 205, in _console_script_run run() File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\__main__.py", line 189, in run run_build(pyi_config, spec_file, **vars(args)) File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\__main__.py", line 61, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\building\build_main.py", line 1043, in main build(specfile, distpath, workpath, clean_build) File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\building\build_main.py", line 982, in build exec(code, spec_namespace) File "H:\Data Collation-222\pyMyproject\001 Module Verification\pyinstall Verification\create_file.spec", line 4, in <module> a = Analysis( File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\building\build_main.py", line 468, in __init__ self.__postinit__() File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__ self.assemble() File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\building\build_main.py", line 800, in assemble self.binaries.extend(find_binary_dependencies(self.binaries, collected_packages)) File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\building\build_main.py", line 232, in find_binary_dependencies return bindepend.binary_dependency_analysis(binaries, search_paths=extra_libdirs) File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\depend\bindepend.py", line 122, in binary_dependency_analysis parent_dir_preservation_paths = _get_paths_for_parent_directory_preservation() File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\depend\bindepend.py", line 74, in _get_paths_for_parent_directory_preservation print('my orig_paths list:::',[pathlib.Path(path).resolve() for path in orig_paths]) File "D:\11_job\anaconda3_20201121\lib\site-packages\PyInstaller\depend\bindepend.py", line 74, in <listcomp> print('my orig_paths list:::',[pathlib.Path(path).resolve() for path in orig_paths]) File "D:\11_job\anaconda3_20201121\lib\pathlib.py", line 1177, in resolve s = self._flavour.resolve(self, strict=strict) File "D:\11_job\anaconda3_20201121\lib\pathlib.py", line 205, in resolve s = self._ext_to_normal(_getfinalpathname(s)) OSError: [WinError 123] The file name, directory name, or volume label syntax is incorrect. : 'D:\t_job\x07naconda3_20201121\Lib\site-packages'
According to the error path, find the variable location of path, modify the source code, and print the path to confirm the problem, because pyinstaller is an installation program and cannot debug (print is another form of debug)
pathlib.Path(path).resolve() for path in orig_paths
It was found that the impact returned by site.getusersitepackages() was investigated further. The following location was found, the USER_SITE environment variable was configured, and r was added in front of the string to indicate no escaping, which can be solved;
Note, in addition to \11, \a (naconda) is also escaped