mrmaxguns / wonderwordsmodule

Generate random words and sentences with ease in Python. Be on the lookout for bugfixes and speed improvements in 2.3
https://wonderwords.readthedocs.io
MIT License
53 stars 11 forks source link

FileNotFoundError #3

Closed mrmaxguns closed 4 years ago

mrmaxguns commented 4 years ago

After importing the package and using random_word() python gives the following error:

>>> from wonderwords import random_word
>>> my_words = random_word.random_word()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/wonderwords/random_word.py", line 9, in __init__
    word_file = open('words.txt', "r")
FileNotFoundError: [Errno 2] No such file or directory: 'words.txt'

I have checked to see if the file is in the same directory as the python file, and it is. This shouldn't happen as when a user installs the package, they will get this error. Both files are located in:

/usr/local/lib/python3.7/site-packages/wonderwords
mrmaxguns commented 4 years ago

Solved using importlib_resources