How To Add A Binary Data File In The Same Directory As Of Exe Using Pyinstaller?
I have a binary text file which I want to embed in --onefile
using pyinstaller.
The text file should be in the same directory as of the program.
I used pyinstaller --onefile --add-binary a.txt;. A.py
but it creates an error PermissionError: [Errno 13] Permission denied: 'C:\\Users\\name\\Appdata\Local\pyinstaller\bin000cache\a.txt
Answer
try running as admin, the file doesnt let the executable access it.... optionally you can create a py script out of the file from another py script, and have this script just store the binary data as a variable, it would arugably be the same size as the text file, but i wouldnt open the script in an editor
a='txtfile="""'
with open('script.py' as 'wb') as v:
with open('file.txt', 'rb') as f:
a+=f.read()
a+="""'
v.write(a)
use the var = / something for multiple line strings
once you import script.py
it will read all that into memory,but u can del script.txtfile
later
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module