Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with PyInstaller #38

Open
Zenahr opened this issue Sep 23, 2021 · 5 comments
Open

problem with PyInstaller #38

Zenahr opened this issue Sep 23, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@Zenahr
Copy link

Zenahr commented Sep 23, 2021

I'm packaging a script as an executable via PyInstaller.

better_profanity always looks for a file in this directory: C:\\Users\\<USERNAME>\\AppData\\Local\\Temp\\_MEI199002\\better_profanity\\alphabetic_unicode.json

Is there a way to select the file for that manually as we can for the wordlist?

Traceback:
Traceback (most recent call last):
  File "gui.py", line 15, in 
  File "", line 991, in _find_and_load
  File "", line 975, in _find_and_load_unlocked
  File "", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "app\app.py", line 3, in 
  File "", line 991, in _find_and_load
  File "", line 975, in _find_and_load_unlocked
  File "", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "better_profanity\__init__.py", line 3, in 
  File "", line 991, in _find_and_load
  File "", line 975, in _find_and_load_unlocked
  File "", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "better_profanity\better_profanity.py", line 5, in 
  File "", line 991, in _find_and_load
  File "", line 975, in _find_and_load_unlocked
  File "", line 671, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "better_profanity\constants.py", line 14, in 
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\\\AppData\\Local\\Temp\\_MEI199002\\better_profanity\\alphabetic_unicode.json'
@jcbrockschmidt
Copy link
Collaborator

Have you tried using --add-data like in this solution? If that doesn't work, could you provide steps to reproduce this error?

@Zenahr
Copy link
Author

Zenahr commented Sep 29, 2021

@jcbrockschmidt Yes, I did. I'll try to get back to you to reproduce. However, I've moved on to an alternative lib.

@jcbrockschmidt jcbrockschmidt added the bug Something isn't working label Sep 29, 2021
@jcbrockschmidt
Copy link
Collaborator

@jcbrockschmidt Yes, I did. I'll try to get back to you to reproduce. However, I've moved on to an alternative lib.

In that case, it's probably because we're reading files in a non-standardized way. I suspect we'll want to do something like this. Labeling as a bug.

@jonathan-attard
Copy link

Can you use this?

bundle_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
file_path = os.path.join(bundle_dir, file_name)

@WilHall
Copy link

WilHall commented Apr 10, 2024

The above solutions do not work for me on the latest pyinstaller with Python 3.5 - the .env file is still not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants