我有一个脚本,使用了来自conda-forge的yfinance包。它从包中提取了一些关于某些股票的信息,然后将所述信息复制到剪贴板,这样就可以快速粘贴到基于文本的文档中。该脚本从我的Pycharm IDE运行,没有任何问题,但当我使用Pyinstaller将其打包到一个文件中时,我遇到了FileNotFoundError。以下是我得到的追溯:
Traceback (most recent call last):
File "pw_news_aggregator.py", line 2, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "yfinance\__init__.py", line 23, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "yfinance\ticker.py", line 29, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "yfinance\base.py", line 32, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "yfinance\data.py", line 18, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "frozendict\__init__.py", line 33, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\USER~1\\AppData\\Local\\Temp\\_MEI151882\\frozendict\\VERSION'
[27792] Failed to execute script 'pw_news_aggregator' due to unhandled exception!
我的Pyinstaller powershell命令是:pyinstaller --onefile --name非常基本,过去它工作时没有任何问题。
下面是我的.spec文件:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['C:\\Users\\USER\\Coding\\Projects\\Portfolio_Watch\\pw_news_aggregator.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='PW News Aggregator',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
我试着做一个新的conda env,以为它可能被损坏了。但是每次都会发生同样的错误。我不知道为什么frozendict会引起任何问题,它看起来是安装好的。
另外,在回溯中,C路径包含了一个不正确的用户名,我不确定这是Pyinstaller做的一个编辑还是什么,它是:'C:\用户\名字姓氏首字母~1...',而它应该是'C:\用户\名字姓氏...'
任何想法都非常感谢!谢谢!
1条答案
按热度按时间vltsax251#
不知道你是否已经找到了答案,但我能够得到确切的yfinance exe错误,因为你的工作,通过以下线程。
PyInstaller: FIleNotFoundError