Reputation: 945
Trying to run pyinstaller to compile a tensorflow application on windows. The file get's packaged perfectly, but i end up running into this error when running the resulting exe.
File "site-packages\astor\__init__.py", line 24, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\me\\AppData\\Local\\Temp\\_MEI138162\\astor\\VERSION'
I've ensured the astor
package is included, and even tried to use the --hiden imports
flag, but to no avail.
How can I properly include the astor package with pyinstaller?
Upvotes: 4
Views: 2034
Reputation: 155
I fixed this problem by going in to the astor/init.py file and changing the two lines you mentioned in your question to:
__version__ = '0.8.1'
parse_file = code_to_ast.parse_file
Pyinstaller worked perfectly after this.
Upvotes: 1
Reputation: 196
I've run into the same issue and here is how I solved it without requiring any manual copy/paste:
In my .spec
file, I've added the following lines:
from PyInstaller.utils.hooks import collect_data_files
a.datas += collect_data_files('astor', subdir=None, include_py_files=False)
Explanation
The error pointed to this statement in the site-packages' astor/__init__.py
:
with open(os.path.join(ROOT, 'VERSION')) as version_file:
__version__ = version_file.read().strip()
It seemed that the VERSION
file present in the astor package was not being copied by pyinstaller, and therefore not found in the standalone folder produced. Using the collect_data_files()
utils function and adding the results to the analysis' datas
argument in my .spec
file resolved the issue. Detailed info in the docs: https://pyinstaller.readthedocs.io/en/stable/hooks.html?highlight=collect_data_files#useful-items-in-pyinstaller-utils-hooks
Upvotes: 1
Reputation: 11
I faced the same problem. My astor package version was 0.8.1. I changed astor version to 0.7.1. It worked like a charm.
Upvotes: 0
Reputation: 59
You can create "astor" folder in your project. And paste VERSION file from "your env/Lib/site-packages/astor/VERSION".
-- [EDIT] --
On PyInstaller you should add the flag --add-data 'astor:./astor'
to add the folder to the project, doesn't seem to need the source, just the VERSION
file
Upvotes: 4