#困っていること
青空文庫から作品データをダウンロードし、Janomeを利用して品詞を得るプログラムを作っているのですが、janomeをインストールしたのにエラーが出ます。どうすればいいでしょうか?
#該当のソースコード
python
1import urllib.request 2 3from janome.analyzer import Analyzer 4from janome.charfilter import * 5from janome.tokenizer import Tokenizer 6 7 8class MainTextCharFilter(CharFilter): 9 10 def __init__(self, start, end): 11 self.start = start 12 self.end = end 13 14 def apply(self, text): 15 return text.split(self.start)[1].split(self.end)[0] 16 17# 夏目漱石 18# 吾輩は猫である 19url = 'http://www.aozora.gr.jp/cards/000148/files/789_14547.html' 20 21html = '' 22 23with urllib.request.urlopen(url) as response: 24 html = response.read().decode('shift_jis') 25 26 27char_filters = [UnicodeNormalizeCharFilter(), 28 MainTextCharFilter('<div class="main_text">', '<div class="bibliographical_information">'), 29 RegexReplaceCharFilter('<rp>(.*?)</rp>', ''), 30 RegexReplaceCharFilter('<.*?>', '')] 31 32tokenizer = Tokenizer() 33 34analyzer = Analyzer(char_filters, tokenizer) 35 36for token in analyzer.analyze(html): 37 print(token) 38
#エラーメッセージ
python
1Traceback (most recent call last): 2 File "ディレクトリ名", line 3, in <module> 3 from janome.analyzer import Analyzer 4ModuleNotFoundError: No module named 'janome'
#janomeインストール画面(Anaconda prompt)
#回答を受けて追記
pip show janomeを入力した結果
import sys;print(sys.prefix)を入力した結果
回答1件
あなたの回答
tips
プレビュー