Closed teruto725 closed 2 years ago
I report about the error.
I installed requirements.txt that includes jamdict by "pip install -r ./backend/requirements.txt".
However, backend/Infocontroller.py doesn't work. The error is below.
File "/Users/takumi-hi/kanji-visualization/kanji-visualization/backend/InfoController.py", line 3, in
The code InfoController.py is below.
from jamdict import Jamdict class InfoController:
def get_jamdict_data():
jam = Jamdict()
print("query: ", end="")
query = input()
result = jam.lookup(query)
index = -1
print(result)
get_jamdict_data()
@TakumiHiraide
Sorry, the current ./backend/requirements.txt
contains only the libraries that were needed to build the development environment, so please add more libraries as needed.
In this case, please run pip install jamdict jamdict-data
on your terminal, and edit ./backend/requirements.txt
as follows:
flake8
black
mypy
pytest
pre-commit
fastapi
uvicorn
jamdict
jamdict-data
This will ensure that the latest dependent libraries are installed when others run pip install -r ./backend/requirements.txt
.
Sorry, I did what you said, but it still doesn't work. Maybe I have another problem.
The error is same from jamdict import Jamdict ModuleNotFoundError: No module named 'jamdict'
@TakumiHiraide By the way, can you run this file without errors? https://gist.github.com/wowry/840715df27d75171c5a8456e76275862
No, not yet because the first "from jamdict import Jamdict" throws an error "ModuleNotFoundError: No module named 'jamdict' ".
@TakumiHiraide
OK, then please run pip list
and check the list contains the libraries you expected.
I made sure that list contained "jamdict and jamdict-data"
Does it work for you?
My folder structure is here. I want to run "InfoController.py" which is same to "sample_jamdict.py"
Hmm... It looks strange (because kanji-visualization
in kanji-visualization
), but there seems to be no problem.
Yes, it works in my local environment.
Could you send me the screenshot of your InfoController.py
?
InfoController2 is completely the same "sample_jamdict.py" you prepare. Both programs throw the same error "ModuleNotFoundError: No module named 'jamdict' ".
Ok so may I summarize? As far as I understood, we still didn't understand where isn't visible the jamdict module, in your local machine? or in VisualStudio terminal environment? I just tried same and it worked on my machine so from my understanding to have nested directories isn't good, because you have now 2 git repositories nested each other, as said @wowry the kanji-visualization directory is nested in KANJI-VISUALIZATION directory.
TEST ENVIRONMENT
Can you do this to check if jamdict is working in whole computer?
Step 1. Open new terminal without visual studio code and type:
$ python3
Step 2. Now type:
from jamdict import Jamdict
Step 3. if you see nothing is printed after 2nd step then jamdict worked! That means the problem is that you have nested directories, MAYBE! Please try to make one directory with one .github directory inside (not nested).
But if it 2nd step says can't find .... then jamdict isn't installed in your local machine.
To fix that at this point and to continue coding, you can open again new terminal and type same as @wowry said before : $ pip install jamdict jamdict-data (I guess as you see the pip list this won't be the case now)
TEST CODE But if you want to make sure if simple jamdict code will work try this testing steps:
cd ~/; mkdir test-jamdict; cd test-jamdict; touch jd.py
from jamdict import Jamdict
jam = Jamdict()
result = jam.lookup('食べ%る')
for entry in result.entries:
print(entry)
for c in result.chars:
print(repr(c))
print("If you see this message them JAMDICT WORKED in your computer !!!")
3. Now go back to the same terminal and type
$ `python3 jd.py`
4. Now you should see the printed last message
5. OPTIONAL. Now go to your project directory then open terminal and do the same as from TEST CODE ?
That's exactly what I want to say!
That's exactly what I want to say!
Sorry for stoling your thoughts ))) I saw many emails coming from this issue and checked in my side then typed same steps as I did in my machine ^^
Nice, thank you very much for your support!
Everyone, thank you so much. I fixed nested directories, but it doesn't work. So, I use terminal application, then I don't know why, but it worked. .
Great, then you can move on to coding. It "worked" because jamdict is really installed in your machine. About "didn't work" we'll think of that later, as we don't have much time on development environment (VisualStudio specific) fixes this week.
Maybe following the steps in the link below will be solve this error, but yes, we don't have much time this week as ani san said, so don't think too much! :)
I made InfoController, but "kanji_info" and "error_info" are list type. Is it OK? I'm not sure if this will be reflected in the frontend.
Sorry. It's not good. You should use dictionary instead of list. you chan just fix likes below.
kanji_info = {"onyomi":yomi, "meaning", meaning}
and kanji info is also needed kunyomi right?
Thank you for your advice. Now the code can output the kun-yomi, on-yomi, and meaning using the dict type as shown below. But I'm not confident about my code, because I assume the first part of [Entries] to be kun-yomi and the second part to be on-yomi. I'm really sorry .
Commit 3368901c
We've doen pair programmign with Hiraide san and Ihara san. And fixed local environment issues, not all works fine.
Create Info controller